OpenBB-finance/OpenBB · error · ValueError

Target column '{target}' not found in data. Choose from {cho

Error message

Target column '{target}' not found in data. Choose from {choices}

What it means

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 ...'.

Source

Thrown at openbb_platform/core/openbb_core/app/utils.py:153

    if isinstance(data, Data) or issubclass(type(data), Data):
        return data
    if isinstance(data, list):
        return list_to_basemodel(data)
    if isinstance(data, dict):
        return dict_to_basemodel(data)
    if isinstance(data, (DataFrame, Series)):
        return df_to_basemodel(data)
    if isinstance(data, ndarray):
        return ndarray_to_basemodel(data)
    raise ValueError(f"Unsupported data type: {type(data)}")


def get_target_column(df: "DataFrame", target: str) -> "Series":
    """Get target column from time series data."""
    if target not in df.columns:
        choices = ", ".join(df.columns)
        raise ValueError(
            f"Target column '{target}' not found in data. Choose from {choices}"
        )
    return df[target]


def get_target_columns(df: "DataFrame", target_columns: list[str]) -> "DataFrame":
    """Get target columns from time series data."""
    # pylint: disable=import-outside-toplevel
    from pandas import DataFrame

    df_result = DataFrame()
    for target in target_columns:
        df_result[target] = get_target_column(df, target).to_frame()
    return df_result


def get_user_cache_directory() -> str:
    """Get user cache directory."""

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Pick a target from the columns listed in the error message
  2. Inspect available columns first: res.to_df().columns.tolist()
  3. Rename/add the desired column in the DataFrame before calling the indicator
  4. Switch provider if you need a column (e.g. adj_close) it doesn't emit

Example fix

# before
res = obb.equity.price.historical('AAPL', provider='yfinance')
out = res.charting.ta.sma(length=20, target='adj_close')

# after
res = obb.equity.price.historical('AAPL', provider='yfinance')
out = res.charting.ta.sma(length=20, target='close')
Defensive patterns

Strategy: validation

Validate before calling

def target_exists(df, target: str) -> bool:
    return target in df.columns

Type guard

def is_valid_target(df, target: str) -> bool:
    return isinstance(target, str) and target in set(df.columns)

Try / catch

try:
    out = res.charting.ta.sma(length=20, target=target)
except ValueError as e:
    if 'not found in data' in str(e):
        target = 'close' if 'close' in res.to_df().columns else res.to_df().columns[0]
        out = res.charting.ta.sma(length=20, target=target)
    else:
        raise

Prevention

When it happens

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

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

Related errors


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