OpenBB-finance/OpenBB · error · ValueError
Data is empty
Error message
Data is empty
What it means
The equity market-cap history chart converts its input to a DataFrame indexed by date and pivots on values='market_cap'; if the frame is empty after conversion, it raises ValueError('Data is empty'). An empty result means the upstream request returned no records (or the injected data/list contained none), so there is nothing to plot.
Source
Thrown at openbb_platform/extensions/equity/openbb_equity/equity_views.py:62
title = kwargs.pop("title", "Historical Market Cap")
data = DataFrame()
if "data" in kwargs and isinstance(kwargs["data"], DataFrame):
data = kwargs["data"]
elif "data" in kwargs and isinstance(kwargs["data"], list):
data = basemodel_to_df(kwargs["data"], index=kwargs.get("index", "date")) # type: ignore
else:
data = basemodel_to_df(
kwargs["obbject_item"],
index=kwargs.get("index", "date"), # type: ignore
)
if "date" in data.columns:
data = data.set_index("date")
if data.empty:
raise ValueError("Data is empty")
df = data.pivot(columns="symbol", values="market_cap")
scatter_kwargs = kwargs.pop("scatter_kwargs", {})
if "hovertemplate" not in scatter_kwargs:
scatter_kwargs["hovertemplate"] = "%{y}"
ytital = kwargs.pop("ytitle", "Market Cap ($)")
y = kwargs.pop("y", df.columns.tolist())
fig = line_chart(
data=df,
title=title,
y=y,
ytitle=ytital,
same_axis=True,
scatter_kwargs=scatter_kwargs,View on GitHub (pinned to 3e071fcc2c)
Solutions
- Check the raw response first: res = obb.equity.fundamental.marketcap(symbol); if not res.results: handle empty.
- Verify the symbol is valid and covered by the provider; try a different provider.
- Widen/remove start_date & end_date filters.
- If injecting data, ensure the list/DataFrame is non-empty and includes 'market_cap' and 'date'.
Example fix
# before
fig = obb.equity.fundamental.marketcap('INVALID', provider='fmp').charting.to_chart()
# after
res = obb.equity.fundamental.marketcap('AAPL', provider='fmp')
if not res.results:
raise SystemExit('no market cap data for symbol/provider')
fig = res.charting.to_chart() Defensive patterns
Strategy: validation
Validate before calling
res = obb.equity.fundamental.marketcap('AAPL', provider='fmp')
assert res.results, 'provider returned no market cap records'
df = res.to_df()
assert {'date', 'market_cap'}.issubset(df.columns) Type guard
def is_nonempty_marketcap_frame(df) -> bool:
"""True when the frame has rows plus date/market_cap columns."""
return (
df is not None
and not df.empty
and {'date', 'market_cap'}.issubset(getattr(df, 'columns', []))
) Try / catch
try:
fig = res.charting.to_chart()
except ValueError as e:
if str(e) == 'Data is empty':
res = obb.equity.fundamental.marketcap(symbol, provider='fmp')
fig = res.charting.to_chart()
else:
raise Prevention
- Check res.results is non-empty before charting.
- Validate the symbol and try alternate providers when empty.
- Loosen date filters in automated pipelines.
When it happens
Trigger: Calling obb.equity.fundamental.marketcap(...).charting.to_chart() (or equity_views.py:62 view) for a symbol with no market-cap history from the provider; passing an empty list in kwargs['data']; a date range outside the provider's coverage.
Common situations: Delisted/illiquid tickers, provider plans that exclude historical market cap, bad symbols, or date filters excluding all rows.
Related errors
- Error: No data to plot.
- No data found to plot.
- Error: No data to plot.
- Error: No data to plot.
- No data was found in the DataFrame.
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/08bdd74a33a2f501.
Report an issue: GitHub.