I know there has been a change on Yahoo finance for fetching data but I dont know how to fix it for my program on google collaboratory. To get the data I am using this code:
df = web.DataReader('AAPL', data_source='yahoo', start='2012-01-01', end='2021-04-15')
df
I then get an error saying cannot fetch code, is there any fixes or an alternative I can use? This is the error:
RemoteDataError Traceback (most recent call last) in () ----> 1 df = web.DataReader('AAPL', data_source='yahoo', start='2012-01-01', end='2021-04-15') 2 df
Upgrade your pandas_datareader to .10 (pip install pandas_datareader --upgrade
)
With pdr 0.9 you'll get:
---------------------------------------------------------------------------
RemoteDataError Traceback (most recent call last)
<ipython-input-47-de79fadf5dea> in <module>
1 import pandas_datareader as pdr
----> 2 df = pdr.DataReader('AAPL', data_source='yahoo', start='2012-01-01', end='2021-04-15')
etc.
With pdr .10 you'll get
The fix was documented here: https://pandas-datareader.readthedocs.io/en/latest/whatsnew.html
Bug Fixes
- Fixed Yahoo readers which now require headers
Many thanks to the Pandas team for fixing this so quickly!