Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas Datareader not responding, HTTP status 404

I am trying to get the historical price data of a company (APPLE in this case) using pandas datareader in python using data_source as Yahoo.

This worked perfectly until just a few days ago (July 2021). I am not sure if Yahoo has discontinued their API again or is it just me.

import pandas_datareader as wb
data = wb.DataReader('AAPL', data_source='yahoo', start='2019-9-1')
print(data) 

Here's the error I get:

Traceback (most recent call last):
  File "C:/Users/Allwin/Documents/GitHub/Dynamic_Programming/Apna Col/scratchBook.py", line 4, in <module>
    data = wb.DataReader('AAPL', data_source='yahoo', start='2019-9-1')
  File "C:\Users\Allwin\anaconda3\envs\Complete_FinAnalysis\lib\site-packages\pandas\util\_decorators.py", line 199, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\Allwin\anaconda3\envs\Complete_FinAnalysis\lib\site-packages\pandas_datareader\data.py", line 376, in DataReader
    return YahooDailyReader(
  File "C:\Users\Allwin\anaconda3\envs\Complete_FinAnalysis\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\Allwin\anaconda3\envs\Complete_FinAnalysis\lib\site-packages\pandas_datareader\yahoo\daily.py", line 153, in _read_one_data
    resp = self._get_response(url, params=params)
  File "C:\Users\Allwin\anaconda3\envs\Complete_FinAnalysis\lib\site-packages\pandas_datareader\base.py", line 181, in _get_response
    raise RemoteDataError(msg)
pandas_datareader._utils.RemoteDataError: Unable to read URL: https://finance.yahoo.com/quote/AAPL/history?period1=1567299600&period2=1625273999&interval=1d&frequency=1d&filter=history
Response Text:
b'<!DOCTYPE html>\n  <html lang="en-us"><head>\n  <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n      <meta charset="utf-8">\n      <title>Yahoo</title>\n      <meta name="viewport" content="width=device-width,initial-scale=1,minimal-ui">\n      <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">\n      <style>\n  html {\n      height: 100%;\n  }\n  body {\n      background: #fafafc url(https://s.yimg.com/nn/img/sad-panda-201402200631.png) 50% 50%;\n      background-size: cover;\n      height: 100%;\n      text-align: center;\n      font: 300 18px "helvetica neue", helvetica, verdana, tahoma, arial, sans-serif;\n  }\n  table {\n      height: 100%;\n      width: 100%;\n      table-layout: fixed;\n      border-collapse: collapse;\n      border-spacing: 0;\n      border: none;\n  }\n  h1 {\n      font-size: 42px;\n      font-weight: 400;\n      color: #400090;\n  }\n  p {\n      color: #1A1A1A;\n  }\n  #message-1 {\n      font-weight: bold;\n      margin: 0;\n  }\n  #message-2 {\n      display: inline-block;\n      *display: inline;\n      zoom: 1;\n      max-width: 17em;\n      _width: 17em;\n  }\n      </style>\n  <script>\n    document.write(\'<img src="//geo.yahoo.com/b?s=1197757129&t=\'+new Date().getTime()+\'&src=aws&err_url=\'+encodeURIComponent(document.URL)+\'&err=%<pssc>&test=\'+encodeURIComponent(\'%<{Bucket}cqh[:200]>\')+\'" width="0px" height="0px"/>\');var beacon = new Image();beacon.src="//bcn.fp.yahoo.com/p?s=1197757129&t="+new Date().getTime()+"&src=aws&err_url="+encodeURIComponent(document.URL)+"&err=%<pssc>&test="+encodeURIComponent(\'%<{Bucket}cqh[:200]>\');\n  </script>\n  </head>\n  <body>\n  <!-- status code : 404 -->\n  <!-- Not Found on Server -->\n  <table>\n  <tbody><tr>\n      <td>\n      <h1 style="margin-top:20px;">Will be right back...</h1>\n      <p id="message-1">Thank you for your patience.</p>\n      <p id="message-2">Our engineers are working quickly to resolve the issue.</p>\n      </td>\n  </tr>\n  </tbody></table>\n  </body></html>'
like image 844
Allwin DSouza Avatar asked Oct 16 '25 15:10

Allwin DSouza


2 Answers

I had the same error.

I upgraded pandas-datareader from 0.9.0 to 0.10.0. I also upgraded pandas from 1.1.1 to 1.3.0.

The error then disappeared. I do not know which one really solved the issue.

One possible way to upgrade is typing: pip install --upgrade pandas-datareader.

like image 98
thdox Avatar answered Oct 18 '25 07:10

thdox


I have the same issue. Looks like Yahoo website is working but maybe they changed the format. I was able to navigate to the url generated by pandas datareader and find I can manually download the data.

Update:

If you read the error message.. at the end it says:

<!-- status code : 404 -->\n  <!-- Not Found on Server -->\n  <table>\n  <tbody><tr>\n      <td>\n      <h1 style="margin-top:20px;">Will be right back...</h1>\n      <p id="message-1">Thank you for your patience.</p>\n      <p id="message-2">Our engineers are working quickly to resolve the issue.</p>

So, I assume it is a temporal yahoo issue.

like image 26
Mars Sasha Avatar answered Oct 18 '25 06:10

Mars Sasha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!