{"record":{"id":"ddb7c7b6f2a2c78f","repo":"OpenBB-finance/OpenBB","slug":"column-target-or-close-not-found-in-the-da","errorCode":null,"errorMessage":"Column '{target}', or 'close', not found in the data.","messagePattern":"Column '(.+?)', or 'close', not found in the data\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/extensions/technical/openbb_technical/technical_views.py","lineNumber":460,"sourceCode":"        data = basemodel_to_df(data, index=index)\n\n    window = (\n        kwargs.get(\"length\", [])\n        if \"length\" in kwargs and kwargs.get(\"length\") is not None\n        else [50]\n    )\n    offset = kwargs.get(\"offset\", 0)\n    target = (\n        kwargs.get(\"target\")\n        if \"target\" in kwargs and kwargs.get(\"target\") is not None\n        else \"close\"\n    )\n\n    if target not in data.columns and \"close\" in data.columns:\n        target = \"close\"\n\n    if target not in data.columns and \"close\" not in data.columns:\n        raise ValueError(f\"Column '{target}', or 'close', not found in the data.\")\n\n    df = data.copy()\n    if target in data.columns:\n        df = df[[target]]\n        df.columns = [\"close\"]\n    title = (\n        kwargs.get(\"title\")\n        if \"title\" in kwargs and kwargs.get(\"title\") is not None\n        else f\"{ma_type.upper()}\"\n    )\n\n    fig = OpenBBFigure()\n    fig = fig.create_subplots(\n        1,\n        1,\n        shared_xaxes=True,\n        vertical_spacing=0.06,\n        horizontal_spacing=0.01,","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/extensions/technical/openbb_technical/technical_views.py#L442-L478","documentation":"The moving-average charting view (technical_views.py, ma function) raises this ValueError when neither the requested target column nor a fallback 'close' column exists in the data. The MA overlay must be computed on one price series; if data lacks both the specified target (default 'close') and 'close', there is no series to smooth.","triggerScenarios":"Calling the MA chart with kwargs['target']='adj_close' when the frame has no adj_close and no close column; charting an OBBject from an endpoint whose output has no 'close' field (e.g. some macro or custom data); case-mismatched column names like 'Close'.","commonSituations":"Passing target names that don't exist in the provider's schema; using custom DataFrames with uppercase or renamed columns; endpoints whose results never include close prices.","solutions":["Inspect data.columns and pass an existing numeric column as target: charting(target='Close'.lower())","Rename your column to 'close' before calling: df = df.rename(columns={'Close': 'close'})","Use an OBBject from a price endpoint that guarantees a close field"],"exampleFix":"# before\nres.charting(target='adj_close')  # no such column\n\n# after\ndf = res.to_df().rename(columns=str.lower)\nres.charting(data=df, target='close')","handlingStrategy":"type-guard","validationCode":"cols = {c.lower() for c in df.columns}\nassert 'close' in cols or (target and target.lower() in cols), 'no plottable price column'","typeGuard":"def has_price_column(df: pd.DataFrame, target: str | None = None) -> bool:\n    cols = {c.lower() for c in df.columns}\n    return 'close' in cols or (target is not None and target.lower() in cols)","tryCatchPattern":"try:\n    res.charting(target='adj_close')\nexcept ValueError as e:\n    if 'not found in the data' in str(e):\n        res.charting(data=res.to_df().rename(columns=str.lower), target='close')","preventionTips":["Lowercase column names before charting","Verify target exists with 'target in df.columns'","Prefer endpoints guaranteed to include a close field"],"tags":["openbb","charting","moving-average","column-missing"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}