0

Has anyone here encountered a tz_localize attribution error when requesting stock data using the yfinance package and in python?

I would love some help with this. I am having an issue collecting stock data using the yfinance package. Here is my code: Import yfinance as yf tsla = yf.Ticker("TSLA") data =tsla.history(period="max") data The output is an attribution error "index object has no attribute tz_localize". When I run the same code using the AAPL, NVDA, IBM or MSFT it executes. I have read up on the yfinance package and what it means to localize your timezone and their suggestions still result in the same error. Does anyone know how to fix this? I have tried researching this issue but it seems to be very common with no apparent solution. I am using vs code. Any ideas for this newbie?

17th Feb 2022, 6:24 AM
Sonya Lawrence
Sonya Lawrence - avatar
2 Answers
+ 3
Accodding to the bug reports on github, downgrading your pandas to 1.3.5 should temporarily fix the problem.
24th Feb 2022, 1:25 AM
Benjamin Rogers
Benjamin Rogers - avatar
+ 1
Thank you so much. It worked! Not sure why it seems to only like that version of pandasđŸ€”
11th Mar 2022, 5:48 AM
Sonya Lawrence
Sonya Lawrence - avatar