Closed soryko closed 4 months ago
Thank you for raising this issue, @soryko. Can you please give us your pandas version?
Thank you for getting back to me. I'm using version 2.2.2
Thank you for the information. I can replicate your issue once I upgrade to pandas 2.2.2. I think the original approach worked by accident because there was a missing validation in the old pandas version. We will check all instances of melt() soon, but in the meantime, the following approach does the trick:
index_prices = (yf.download(
tickers=symbols,
start="2000-01-01",
end="2022-12-31",
progress=False
))
index_prices = (index_prices
.stack()
.reset_index(level=1, drop=False)
.reset_index()
.rename(columns={
"Date": "date",
"level_1": "symbol",
"Open": "open",
"High": "high",
"Low": "low",
"Close": "close",
"Adj Close": "adjusted",
"Volume": "volume"}
)
)
When running the melt() function in the index_prices.
.melt(ignore_index=False, var_name=["variable", "symbol"])
it returns a ValueError:
ValueError: var_name=['variable', 'symbol'] must be a scalar.