OpenBB-finance/OpenBB · error · ValueError

Column {close_col} not in data

Error message

Column {close_col} not in data

What it means

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.

Source

Thrown at openbb_platform/extensions/technical/openbb_technical/helpers.py:566

    Returns
    -------
    df : DataFrame
        Dataframe of fib levels
    min_date: Timestamp
        Date of min point
    max_date: Timestamp:
        Date of max point
    min_pr: float
        Price at min point
    max_pr: float
        Price at max point
    """
    # pylint: disable=import-outside-toplevel
    from pandas import DataFrame

    if close_col not in data.columns:
        raise ValueError(f"Column {close_col} not in data")

    if start_date and end_date:
        if start_date not in data.index:
            date0 = data.index[data.index.get_indexer([end_date], method="nearest")[0]]
            warn(f"Start date not in data.  Using nearest: {date0}")
        else:
            date0 = start_date
        if end_date not in data.index:
            date1 = data.index[data.index.get_indexer([end_date], method="nearest")[0]]
            warn(f"End date not in data.  Using nearest: {date1}")
        else:
            date1 = end_date

        data0 = data.loc[date0, close_col]
        data1 = data.loc[date1, close_col]

        min_pr = min(data0, data1)
        max_pr = max(data0, data1)

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Print data.columns and pass the exact existing column name.
  2. Rename beforehand: df = df.rename(columns={'adj_close': 'close'}) if needed.
  3. Normalize provider output columns before analysis (OpenBB .to_df() plus a column map).
  4. Default to 'close' unless your data explicitly provides another price column.

Example fix

# before
helper(data, close_col="adj_close")  # data has only 'close'

# after
helper(data, close_col="close")
Defensive patterns

Strategy: type-guard

Validate before calling

assert close_col in data.columns, f"{close_col} not in {list(data.columns)}"

Type guard

def has_close_column(df, close_col: str) -> bool:
    return close_col in df.columns

Try / catch

try:
    result = analysis_helper(data, close_col=close_col)
except ValueError as e:
    if "not in data" in str(e):
        close_col = "close" if "close" in data.columns else "adj_close"
        result = analysis_helper(data, close_col=close_col)
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/2a1ab30541f60998. Report an issue: GitHub.