[Error] yfinance 'Index' object has no attribute 'tz_localize'
AttributeError: 'Index' object has no attribute 'tz_localize'
yfinance를 import
!pip install yahoo-finance
import yfinance as yf
!pip install yahoo-finance
import yfinance as yf
!pip install yahoo-finance
import yfinance as yf
Requirement already satisfied: yahoo-finance in c:\users\g4560\anaconda3\lib\site-packages (1.4.0)
Requirement already satisfied: pytz in c:\users\g4560\anaconda3\lib\site-packages (from yahoo-finance) (2021.3)
Requirement already satisfied: simplejson in c:\users\g4560\anaconda3\lib\site-packages (from yahoo-finance) (3.17.6)
Error
df_amzn = yf.download('AMZN',
start= '2018-01-01',
end='2020-12-31',
progress=False, #진행상황 표시 여부
auto_adjust = False, #False로 하면 Adjust 전의 종가와 후의 종가 모두 확인 가능
actions='inline')
df_amzn
Exception in thread Thread-14:
Traceback (most recent call last):
File "C:\Users\G4560\anaconda3\lib\threading.py", line 973, in _bootstrap_inner
self.run()
File "C:\Users\G4560\anaconda3\lib\threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\G4560\anaconda3\lib\site-packages\multitasking\__init__.py", line 104, in _run_via_pool
return callee(*args, **kwargs)
File "C:\Users\G4560\anaconda3\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\G4560\anaconda3\lib\site-packages\yfinance\multi.py", line 202, in _download_one
return Ticker(ticker).history(period=period, interval=interval,
File "C:\Users\G4560\anaconda3\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'
해결
버전을 업그레이드하면 된다.
pip install --upgrade yfinance
업그레이드하고 restart해야 적용이 되었음.
cf)
pip install -U yfinance pandas
StackOverflow에서 위와 같은 답변이 있어서 실행시켰으나, 무한로딩만 되어 사용X
Author And Source
이 문제에 관하여([Error] yfinance 'Index' object has no attribute 'tz_localize'), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@htright/Error-yfinance-Index-object-has-no-attribute-tzlocalize저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)