{"record":{"id":"2a1ab30541f60998","repo":"OpenBB-finance/OpenBB","slug":"column-close-col-not-in-data","errorCode":null,"errorMessage":"Column {close_col} not in data","messagePattern":"Column (.+?) not in data","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/extensions/technical/openbb_technical/helpers.py","lineNumber":566,"sourceCode":"\n    Returns\n    -------\n    df : DataFrame\n        Dataframe of fib levels\n    min_date: Timestamp\n        Date of min point\n    max_date: Timestamp:\n        Date of max point\n    min_pr: float\n        Price at min point\n    max_pr: float\n        Price at max point\n    \"\"\"\n    # pylint: disable=import-outside-toplevel\n    from pandas import DataFrame\n\n    if close_col not in data.columns:\n        raise ValueError(f\"Column {close_col} not in data\")\n\n    if start_date and end_date:\n        if start_date not in data.index:\n            date0 = data.index[data.index.get_indexer([end_date], method=\"nearest\")[0]]\n            warn(f\"Start date not in data.  Using nearest: {date0}\")\n        else:\n            date0 = start_date\n        if end_date not in data.index:\n            date1 = data.index[data.index.get_indexer([end_date], method=\"nearest\")[0]]\n            warn(f\"End date not in data.  Using nearest: {date1}\")\n        else:\n            date1 = end_date\n\n        data0 = data.loc[date0, close_col]\n        data1 = data.loc[date1, close_col]\n\n        min_pr = min(data0, data1)\n        max_pr = max(data0, data1)","sourceCodeStart":548,"sourceCodeEnd":584,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/extensions/technical/openbb_technical/helpers.py#L548-L584","documentation":"In the draw/analysis helper (openbb_technical/helpers.py), raises when the requested close_col is not among the DataFrame's columns before locating min/max points and fitting trends.","triggerScenarios":"Calling the helper with close_col='adj_close' when the DataFrame's column is 'close' (or vice versa), or with a custom column name that the loaded data does not contain.","commonSituations":"Switching data providers whose schemas differ (some emit 'close', others 'adj_close', 'Close', or provider-prefixed names); lower/upper-case mismatches; using OHLCV DataFrames missing the close column entirely.","solutions":["Print data.columns and pass the exact existing column name.","Rename beforehand: df = df.rename(columns={'adj_close': 'close'}) if needed.","Normalize provider output columns before analysis (OpenBB .to_df() plus a column map).","Default to 'close' unless your data explicitly provides another price column."],"exampleFix":"# before\nhelper(data, close_col=\"adj_close\")  # data has only 'close'\n\n# after\nhelper(data, close_col=\"close\")","handlingStrategy":"type-guard","validationCode":"assert close_col in data.columns, f\"{close_col} not in {list(data.columns)}\"","typeGuard":"def has_close_column(df, close_col: str) -> bool:\n    return close_col in df.columns","tryCatchPattern":"try:\n    result = analysis_helper(data, close_col=close_col)\nexcept ValueError as e:\n    if \"not in data\" in str(e):\n        close_col = \"close\" if \"close\" in data.columns else \"adj_close\"\n        result = analysis_helper(data, close_col=close_col)\n    else:\n        raise","preventionTips":["Inspect data.columns from each provider once and map them","Rename provider columns to a canonical schema","Default to 'close'"],"tags":["columns","technical","validation","schema"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}