{"record":{"id":"b4a4165510626a09","repo":"OpenBB-finance/OpenBB","slug":"target-column-target-not-found-in-data-choose","errorCode":null,"errorMessage":"Target column '{target}' not found in data. Choose from {choices}","messagePattern":"Target column '(.+?)' not found in data\\. Choose from (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/core/openbb_core/app/utils.py","lineNumber":153,"sourceCode":"\n    if isinstance(data, Data) or issubclass(type(data), Data):\n        return data\n    if isinstance(data, list):\n        return list_to_basemodel(data)\n    if isinstance(data, dict):\n        return dict_to_basemodel(data)\n    if isinstance(data, (DataFrame, Series)):\n        return df_to_basemodel(data)\n    if isinstance(data, ndarray):\n        return ndarray_to_basemodel(data)\n    raise ValueError(f\"Unsupported data type: {type(data)}\")\n\n\ndef get_target_column(df: \"DataFrame\", target: str) -> \"Series\":\n    \"\"\"Get target column from time series data.\"\"\"\n    if target not in df.columns:\n        choices = \", \".join(df.columns)\n        raise ValueError(\n            f\"Target column '{target}' not found in data. Choose from {choices}\"\n        )\n    return df[target]\n\n\ndef get_target_columns(df: \"DataFrame\", target_columns: list[str]) -> \"DataFrame\":\n    \"\"\"Get target columns from time series data.\"\"\"\n    # pylint: disable=import-outside-toplevel\n    from pandas import DataFrame\n\n    df_result = DataFrame()\n    for target in target_columns:\n        df_result[target] = get_target_column(df, target).to_frame()\n    return df_result\n\n\ndef get_user_cache_directory() -> str:\n    \"\"\"Get user cache directory.\"\"\"","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/core/openbb_core/app/utils.py#L135-L171","documentation":"ValueError from get_target_column, a helper used by charting/technical-analysis code that extracts a named column from a time-series DataFrame before computing indicators. If the requested target (e.g. 'adj_close') is not among df.columns, it raises this error listing the available column names as 'Choose from ...'.","triggerScenarios":"Calling charting/ta functions like obb.equity.price.historical(...).charting.ta.sma(target='high') where the provider's result lacks a 'high' column; passing 'adj_close' when the provider (e.g. yfinance daily) only returned 'close'; case-mismatched column names.","commonSituations":"Provider schema differences (some emit 'adj_close', others 'close'); standardized vs extra column confusion; misspelled target; using a DataFrame from a custom source whose columns don't follow OpenBB standard names.","solutions":["Pick a target from the columns listed in the error message","Inspect available columns first: res.to_df().columns.tolist()","Rename/add the desired column in the DataFrame before calling the indicator","Switch provider if you need a column (e.g. adj_close) it doesn't emit"],"exampleFix":"# before\nres = obb.equity.price.historical('AAPL', provider='yfinance')\nout = res.charting.ta.sma(length=20, target='adj_close')\n\n# after\nres = obb.equity.price.historical('AAPL', provider='yfinance')\nout = res.charting.ta.sma(length=20, target='close')","handlingStrategy":"validation","validationCode":"def target_exists(df, target: str) -> bool:\n    return target in df.columns","typeGuard":"def is_valid_target(df, target: str) -> bool:\n    return isinstance(target, str) and target in set(df.columns)","tryCatchPattern":"try:\n    out = res.charting.ta.sma(length=20, target=target)\nexcept ValueError as e:\n    if 'not found in data' in str(e):\n        target = 'close' if 'close' in res.to_df().columns else res.to_df().columns[0]\n        out = res.charting.ta.sma(length=20, target=target)\n    else:\n        raise","preventionTips":["Check df.columns before choosing a target","Normalize/rename provider columns to OpenBB standard names upstream","Default to 'close' - present in virtually all price frames"],"tags":["openbb","dataframe","columns","technical-analysis"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}