79378705

Date: 2025-01-22 17:35:42
Score: 0.5
Natty:
Report link

Unexpert opinion here after fiddling around with your code and chatgpt.

For your particular setup, there is some difference in the .columns between the data frames.

>>> df.columns
Index(['ds', 'y'], dtype='object')
>>> ld.columns  # lululemon_data
MultiIndex([('ds',     ''),
            ( 'y', 'LULU')],
           names=['Price', 'Ticker'])

I am not sure what the exact difference is, but it's probably used by yfinance to differentiate between multiple tickers. From the documentation for yfinance.download,

multi_level_index: bool

Optional. Always return a MultiIndex DataFrame? Default is True

I toggled multi_level_index to False, which seems to fix your code.

lululemon_data = yf.download(ticker, start='2007-07-27', multi_level_index=False)  # Lululemon IPO date

For other cases where getting the underlying library cannot output an applicable type, maybe this thread can help to flatten a MultiIndex.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Xerus Lord