TypeError on pandas webreader
Question:
I am trying to get stock date using the web datareader library and i am receiving an error i have never gotten before even thought i have not changed anything
import datetime as dt
from datetime import datetime, timedelta, date
import pandas_datareader.data as web
start = date(2010,10,1)
end = datetime.now()
df = web.DataReader("AAPL", 'yahoo', start, end)
print(df)
The full error i receive reads as follows
Traceback (most recent call last):
File "d:codenewgennewmain.py", line 60, in <module>
df = web.DataReader("AAPL", 'yahoo', start, end)
File "C:UsersOwnerAppDataLocalPackagesPythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0LocalCachelocal-packagesPython310site-packagespandasutil_decorators.py", line 211, in wrapper
return func(*args, **kwargs)
File "C:UsersOwnerAppDataLocalPackagesPythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0LocalCachelocal-packagesPython310site-packagespandas_datareaderdata.py", line 379, in DataReader
).read()
File "C:UsersOwnerAppDataLocalPackagesPythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0LocalCachelocal-packagesPython310site-packagespandas_datareaderbase.py", line 253, in read
df = self._read_one_data(self.url, params=self._get_params(self.symbols))
File "C:UsersOwnerAppDataLocalPackagesPythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0LocalCachelocal-packagesPython310site-packagespandas_datareaderyahoodaily.py", line 153, in _read_one_data
data = j["context"]["dispatcher"]["stores"]["HistoricalPriceStore"]
TypeError: string indices must be integers
Answers:
what worked for me was downgrading the webreader package to 0.9.0 and then using yfinance to hijack it as such
from pandas_datareader import data as pdr
import yfinance as yf
yf.pdr_override()
# download dataframe
data = pdr.get_data_yahoo("SPY", start="2017-01-01", end="2017-04-30")
I am trying to get stock date using the web datareader library and i am receiving an error i have never gotten before even thought i have not changed anything
import datetime as dt
from datetime import datetime, timedelta, date
import pandas_datareader.data as web
start = date(2010,10,1)
end = datetime.now()
df = web.DataReader("AAPL", 'yahoo', start, end)
print(df)
The full error i receive reads as follows
Traceback (most recent call last):
File "d:codenewgennewmain.py", line 60, in <module>
df = web.DataReader("AAPL", 'yahoo', start, end)
File "C:UsersOwnerAppDataLocalPackagesPythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0LocalCachelocal-packagesPython310site-packagespandasutil_decorators.py", line 211, in wrapper
return func(*args, **kwargs)
File "C:UsersOwnerAppDataLocalPackagesPythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0LocalCachelocal-packagesPython310site-packagespandas_datareaderdata.py", line 379, in DataReader
).read()
File "C:UsersOwnerAppDataLocalPackagesPythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0LocalCachelocal-packagesPython310site-packagespandas_datareaderbase.py", line 253, in read
df = self._read_one_data(self.url, params=self._get_params(self.symbols))
File "C:UsersOwnerAppDataLocalPackagesPythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0LocalCachelocal-packagesPython310site-packagespandas_datareaderyahoodaily.py", line 153, in _read_one_data
data = j["context"]["dispatcher"]["stores"]["HistoricalPriceStore"]
TypeError: string indices must be integers
what worked for me was downgrading the webreader package to 0.9.0 and then using yfinance to hijack it as such
from pandas_datareader import data as pdr
import yfinance as yf
yf.pdr_override()
# download dataframe
data = pdr.get_data_yahoo("SPY", start="2017-01-01", end="2017-04-30")