pandas-datareader
pandas-datareader copied to clipboard
Fail to download data from yahoo on 01/13/2023
Hello,
Data download fails from yahoo finance. The error msg is
df = web.DataReader("SPY", data_source='yahoo', start='2020-01-01', end='2020-03-03', session = sesh) Traceback (most recent call last):
File "C:\Users\peter\AppData\Local\Temp/ipykernel_25324/3322276019.py", line 1, in
File "C:\Users\peter\anaconda3\lib\site-packages\pandas\util_decorators.py", line 207, in wrapper return func(*args, **kwargs)
File "C:\Users\peter\anaconda3\lib\site-packages\pandas_datareader\data.py", line 370, in DataReader return YahooDailyReader(
File "C:\Users\peter\anaconda3\lib\site-packages\pandas_datareader\base.py", line 253, in read df = self._read_one_data(self.url, params=self._get_params(self.symbols))
File "C:\Users\peter\anaconda3\lib\site-packages\pandas_datareader\yahoo\daily.py", line 231, in _read_one_data data = new_j['HistoricalPriceStore']
UnboundLocalError: local variable 'new_j' referenced before assignment
It was good yesterday, 01/12/2023. Thanks!
Assume you installed pandas-datareader using this command
pip install git+https://github.com/raphi6/pandas-datareader.git@ea66d6b981554f9d0262038aef2106dda7138316
Faced the same issue today, but based on this commit, overwrote these 3 files:
folder = /path/to/env/env-name/Lib/site-packages
1) pandas_datareader/tests/io/test_jsdmx.py
2) pandas_datareader/tests/yahoo/test_options.py
3) pandas_datareader/yahoo/daily.py
Working as expected, waiting for Issue #952 merge to main branch and a release soon.
It works now. Thanks!
@devmsft-github how did you overwrite the 3 files?
- Saved the 3 original files that came with the
pip installto[filename]_orig.py - from this commit, copied the content of the newest version of file_1
- Opened
[file_1].pyunder/path/to/env/Lib/site-packagesand pasted content from (2) - Repeat for
file_2&file_3
The new files are broken again with yahoo finance
df = web.DataReader("SPY", data_source='yahoo', start='2023-01-01', end='2023-01-13', session = sesh)
Error msg
Traceback (most recent call last):
File "C:\Users\peter\AppData\Local\Temp/ipykernel_27516/630144412.py", line 1, in df = web.DataReader("SPY", data_source='yahoo', start='2023-01-01', end='2023-01-13', session = sesh)
File "C:\Users\peter\anaconda3\lib\site-packages\pandas\util_decorators.py", line 207, in wrapper return func(*args, **kwargs)
File "C:\Users\peter\anaconda3\lib\site-packages\pandas_datareader\data.py", line 370, in DataReader return YahooDailyReader(
File "C:\Users\peter\anaconda3\lib\site-packages\pandas_datareader\base.py", line 253, in read df = self._read_one_data(self.url, params=self._get_params(self.symbols))
File "C:\Users\peter\anaconda3\lib\site-packages\pandas_datareader\yahoo\daily.py", line 227, in _read_one_data new_j = decrypt_cryptojs_aes(
File "C:\Users\peter\anaconda3\lib\site-packages\pandas_datareader\yahoo\daily.py", line 81, in decrypt_cryptojs_aes plaintext = unpad(plaintext, 16, style="pkcs7")
File "C:\Users\peter\anaconda3\lib\site-packages\Crypto\Util\Padding.py", line 92, in unpad raise ValueError("Padding is incorrect.")
ValueError: Padding is incorrect.
Thanks!
This time went the route of yfinance as below
import yfinance as yf
yf.pdr_override()
then
data = yf.download(ticker, start=start_date, end=end_date, threads=False) # or threads=True
This works with raphi6's pandas-datareader fixes I suggested above, so all you need is yfinance.
This still not working !!!
No update on this issue? Is pandas-datareader abandoned?
Hey there,
The yfinance module offers an override of the yahoo finance from datareader.
It only requires to add one line.
from pandas_datareader import data as pdr
import yfinance as yf
yf.pdr_override() # <== that's all it takes :-)
# download dataframe
data = pdr.get_data_yahoo("SPY", start="2017-01-01", end="2017-04-30")
You can check the comment on the official yfinance repo -> here
Hope it helps, it worked for me.