OpenBB-finance/OpenBB · error · ValueError

The expected column labels, {check_columns}, were not found

Error message

The expected column labels, {check_columns}, were not found in DataFrame.

What it means

calculate_heikin_ashi in openbb_charting/charts/helpers.py verifies that open, high, low, close columns (lowercase) all exist before delegating to pandas_ta's candles.ha. If any OHLC label is missing (uppercase, renamed, or absent), the ValueError lists the expected labels so the caller can fix the frame's schema.

Source

Thrown at openbb_platform/obbject_extensions/charting/openbb_charting/charts/helpers.py:89

    ----------
    data: DataFrame
        DataFrame containing OHLC data.

    Returns
    -------
    DataFrame
        DataFrame copy with Heikin Ashi candle calculations.
    """
    # pylint: disable=import-outside-toplevel
    from pandas_ta import candles

    df = data.copy()

    check_columns = ["open", "high", "low", "close"]

    for item in check_columns:
        if item not in df.columns:
            raise ValueError(
                f"The expected column labels, {check_columns}, were not found in DataFrame."
            )

    ha = candles.ha(
        df["open"],
        df["high"],
        df["low"],
        df["close"],
    )

    for item in check_columns:
        df[item] = ha[f"HA_{item}"]

    return df


def duration_sorter(durations: list) -> list:
    """Sort durations labeled as month_5, year_5, etc."""

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Lowercase the columns: df.columns = df.columns.str.lower()
  2. Rename alternative labels: df = df.rename(columns={'Open': 'open', 'High': 'high', 'Low': 'low', 'Close': 'close'})
  3. Ensure the source endpoint returns full OHLC data before requesting candles

Example fix

# before
fig = charting.create_candle_chart(data=df)  # columns: Open/High/Low/Close

# after
df.columns = df.columns.str.lower()
fig = charting.create_candle_chart(data=df)
Defensive patterns

Strategy: validation

Validate before calling

ohlc = {'open', 'high', 'low', 'close'}
missing = ohlc - {c.lower() for c in df.columns}
assert not missing, f'missing OHLC columns: {missing}'
df.columns = df.columns.str.lower()

Type guard

def is_ohlc_frame(df: pd.DataFrame) -> bool:
    cols = {c.lower() for c in df.columns}
    return {'open', 'high', 'low', 'close'}.issubset(cols)

Try / catch

try:
    fig = create_candle_chart(data=df)
except ValueError as e:
    if 'expected column labels' in str(e):
        fig = create_candle_chart(data=df.rename(columns=str.lower))

Prevention

When it happens

Trigger: Calling the candle/Heikin Ashi chart with columns named 'Open','High','Low','Close' (title case from providers or CSV); frames where 'close' exists but 'open' was dropped; charting an endpoint whose output schema lacks full OHLC (e.g. index prices with only close).

Common situations: CSV/Excel imports producing capitalized headers; provider schemas using 'adj_close' or omitting 'open'; custom DataFrames from screeners with partial price data.

Related errors


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