'AttributeError: 'Index' object has no attribute 'tz_localize' with yfinance
'this error occurs only with some stocks, for instance with NFLX, KO or MCD, but not with AAPL or INFy both with yfinance 0.1.63 and 0.1.69, pandas 1.2.3 or 1.4'
import yfinance as yf
from pandas_datareader import data
import os
import numpy as np
import pandas as pd
aapl = yf.download('NFLX', start="2019-01-01", end="2022-01-28")
#aapl = data.DataReader("^VIX", start='2021-1-1', end='2022-01-28', data_source='yahoo')
print(aapl.tail())
Solution 1:[1]
Was trying to download a string of tickers when i ran into this problem. pip install -U yfinance pandas fixed it.
Solution 2:[2]
After upgrading to yfinance version 0.1.70, the problem has gone. My version of pandas is 1.4.1.
use pip install -U yfinance pandas to update.
For reference, my version of yfinance was 0.1.63 and pandas was 1.4.1.
Solution 3:[3]
From what I saw on the Github for YFinance, this is already an issue with the new version of Pandas (source: here). Try installing an older version of pandas with pip install pandas==1.3.5 and see if that helps.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | beans89 |
| Solution 2 | |
| Solution 3 | gregyjames |
