'ImmediateDeprecationError when using data reader

import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
import pandas_datareader.data as web
style.use('ggplot')
start = dt.datetime(2000,1,1)
end = dt.datetime(2016,12,31)

df = web.DataReader('INPX', 'yahoo', start, end) 


ImmediateDeprecationError                 Traceback (most recent call last)
<ipython-input-11-d0b9e16fb581> in <module>()
----> 1 df = web.DataReader('INPX', 'yahoo', start, end)

/anaconda3/lib/python3.6/site-packages/pandas_datareader/data.py in DataReader(name, data_source, start, end, retry_count, pause, session, access_key)
289     """
290     if data_source == "yahoo":
--> 291         raise ImmediateDeprecationError(DEP_ERROR_MSG.format('Yahoo Daily'))
292         return YahooDailyReader(symbols=name, start=start, end=end,
293                                 adjust_price=False, chunksize=25,

ImmediateDeprecationError: 
Yahoo Daily has been immediately deprecated due to large breaks in the API without the
introduction of a stable replacement. Pull Requests to re-enable these data
connectors are welcome.

See https://github.com/pydata/pandas-datareader/issues

I tried the link but I couldn't find the reason why there is an immediate depreciation error. I also tried changing 'yahoo' to 'google' ie:df = web.DataReader('INPX', 'google', start, end) but there is still an error:

/anaconda3/lib/python3.6/site-packages/pandas_datareader/google/daily.py:40: UnstableAPIWarning: 
The Google Finance API has not been stable since late 2017. Requests seem
to fail at random. Failure is especially common when bulk downloading.

warnings.warn(UNSTABLE_WARNING, UnstableAPIWarning)

RemoteDataError                           Traceback (most recent call last)
<ipython-input-12-5d16a3e9b68a> in <module>()
----> 1 df = web.DataReader('INPX', 'google', start, end)

/anaconda3/lib/python3.6/site-packages/pandas_datareader/data.py in DataReader(name, data_source, start, end, retry_count, pause, session, access_key)
313                                  chunksize=25,
314                                  retry_count=retry_count, pause=pause,
--> 315                                  session=session).read()
316 
317     elif data_source == "iex":

/anaconda3/lib/python3.6/site-packages/pandas_datareader/base.py in read(self)
204         if isinstance(self.symbols, (compat.string_types, int)):
205             df = self._read_one_data(self.url,
--> 206                                      params=self._get_params(self.symbols))
207         # Or multiple symbols, (e.g., ['GOOG', 'AAPL', 'MSFT'])
208         elif isinstance(self.symbols, DataFrame):

/anaconda3/lib/python3.6/site-packages/pandas_datareader/base.py in _read_one_data(self, url, params)
 82         """ read one data from specified URL """
 83         if self._format == 'string':
---> 84             out = self._read_url_as_StringIO(url, params=params)
 85         elif self._format == 'json':
 86             out = self._get_response(url, params=params).json()

/anaconda3/lib/python3.6/site-packages/pandas_datareader/base.py in _read_url_as_StringIO(self, url, params)
 93         Open url (and retry)
 94         """
---> 95         response = self._get_response(url, params=params)
 96         text = self._sanitize_response(response)
 97         out = StringIO()

/anaconda3/lib/python3.6/site-packages/pandas_datareader/base.py in _get_response(self, url, params, headers)
153             msg += '\nResponse Text:\n{0}'.format(last_response_text)
154 
--> 155         raise RemoteDataError(msg)
156 
157     def _get_crumb(self, *args):

RemoteDataError: Unable to read URL: https://finance.google.com/finance/historical?q=INPX&startdate=Jan+01%2C+2000&enddate=Dec+31%2C+2016&output=csv
Response Text:

b'Sorry... body { font-family: verdana, arial, sans-serif; background-color: #fff; color: #000; }GoogleSorry...

We\'re sorry...

... but your computer or network may be sending automated queries. To protect our users, we can\'t process your request right now.

See Google Help for more information.

Google Home'.

Thankyou so much for helping!



Solution 1:[1]

A small change as discussed here worked for me. Just use

import pandas_datareader.data as web
sp500 = web.get_data_yahoo('SPY', start=start, end=end)

Solution 2:[2]

The error is self-explanatory; the Yahoo API has changed, so the old Pandas code to read from Yahoo's API no longer works. Have you read this discussion about the API change and its impact on Pandas? Essentially, Pandas can't read the new Yahoo API, and it will take a long time to write new code, so the temporary solution is to raise an ImmediateDeprecationError every time someone tries to use Pandas for the Yahoo API.

Solution 3:[3]

it is obvious that the api get_data_yahoo, goes wrong. Here is my solution:

  • First, install fix_yahoo_finance:

    pip install fix_yahoo_finance --upgrade --no-cache-dir
    
  • next, before you use the api, insert the code:

    import fix_yahoo_finance as yf
    yf.pdr_override()
    

Best wishes!

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 Regi Mathew
Solution 2 Joel
Solution 3 Talha Junaid