Skip to content

fix: coerce get_sp500_prices return value to Series for yfinance >= 0.2 - #17

Merged
konradbachusz merged 1 commit into
mainfrom
fix/sp500-prices-return-series
Apr 26, 2026
Merged

konradbachusz merged 1 commit into
mainfrom
fix/sp500-prices-return-series

Conversation

@konradbachusz

Copy link
Copy Markdown
Owner

yfinance >= 0.2 returns a DataFrame with multi-level columns for single-ticker downloads, so yfinance.download(...)["Close"] yielded a single-column DataFrame instead of a Series. Callers (e.g. PerformanceMetrics auto-fetch path) that downstream did pd.Series(...) on the result hit "The truth value of a DataFrame is ambiguous" in plot_returns_distribution. Coerce to Series at the boundary so the documented return type holds across yfinance versions.

yfinance >= 0.2 returns a DataFrame with multi-level columns for
single-ticker downloads, so `yfinance.download(...)["Close"]` yielded a
single-column DataFrame instead of a Series. Callers (e.g.
PerformanceMetrics auto-fetch path) that downstream did pd.Series(...) on
the result hit "The truth value of a DataFrame is ambiguous" in
plot_returns_distribution. Coerce to Series at the boundary so the
documented return type holds across yfinance versions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@konradbachusz
konradbachusz merged commit 10ea44d into main Apr 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant