Skip to content

pandas-1.4 yfinance-0.1.69 AttributeError: 'Index' object has no attribute 'tz_localize' #939

@peterxie1

Description

@peterxie1

Just upgraded to yfinance-0.1.69 and pandas-1.4 you will likely hit this issue. The code is trivial and used to work fine. Any suggestions?

python-3.9.10
windows 10

python
Python 3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import yfinance as yf
yf.version
'0.1.69'
ticker = "QQQ"
period = "1d"
interval = "5m"
print(ticker, period, interval)
QQQ 1d 5m
yf.download([ticker], period=period, interval=interval)
Exception in thread Thread-3:
Traceback (most recent call last):
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\threading.py", line 973, in _bootstrap_inner
self.run()
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\threading.py", line 910, in run
self._target(*self._args, **self.kwargs)
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\multitasking_init
.py", line 104, in _run_via_pool
return callee(*args, **kwargs)
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\yfinance\multi.py", line 188, in _download_one_threaded
data = _download_one(ticker, start, end, auto_adjust, back_adjust,
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\yfinance\multi.py", line 202, in _download_one
return Ticker(ticker).history(period=period, interval=interval,
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\yfinance\base.py", line 295, in history
df.index = df.index.tz_localize("UTC").tz_convert(
AttributeError: 'Index' object has no attribute 'tz_localize'
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\peter\AppData\Local\Programs\Python\Python39\lib\site-packages\yfinance\multi.py", line 112, in download
_time.sleep(0.01)
KeyboardInterrupt

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions