randomUser786
randomUser786

Reputation: 1655

Pandas Yahoo Finance: AttributeError: 'Index' object has no attribute 'tz_localize'

I am getting this error: AttributeError: 'Index' object has no attribute 'tz_localize' when i try to use the history function... Please have a look enter image description here

Upvotes: 0

Views: 319

Answers (1)

Timeless
Timeless

Reputation: 37777

I can't reproduce the issue with 0.2.18 (latest) :

import yfinance as yf

tesla_stk = yf.Ticker("TSLA")

teslta_data = tesla_stk.history(period="max")

Output :

print(teslta_data)

                  Open   High    Low  Close     Volume  Dividends  Stock Splits
Date                                                                           
2010-06-29 0...   1.27   1.67   1.17   1.59  281494500       0.00          0.00
2010-06-30 0...   1.72   2.03   1.55   1.59  257806500       0.00          0.00
2010-07-01 0...   1.67   1.73   1.35   1.46  123282000       0.00          0.00
...                ...    ...    ...    ...        ...        ...           ...
2023-05-15 0... 167.66 169.76 164.55 166.35  105592500       0.00          0.00
2023-05-16 0... 165.65 169.52 164.35 166.52   96839500       0.00          0.00
2023-05-17 0... 168.41 173.99 167.19 173.11   83557527       0.00          0.00

You might just need to upgrade yfinance or install it from GitHub (see GH1332 & GH1080).

Upvotes: 1

Related Questions