Skip to content

Commit feee4d7

Browse files
addisonlynchbashtage
authored andcommitted
CLN/REF: Mark deprecated Google finance API (#537)
* Deprecated Google finance API * Added additional docs entry
1 parent 2fa051e commit feee4d7

File tree

5 files changed

+28
-67
lines changed

5 files changed

+28
-67
lines changed

docs/source/remote_data.rst

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717
Remote Data Access
1818
******************
1919

20+
.. warning::
21+
22+
Yahoo! Finance and Google Finance hav been immediately deprecated. Endpoints from both providers have been retired
2023

2124
.. _remote_data.data_reader:
2225

2326
Functions from :mod:`pandas_datareader.data` and :mod:`pandas_datareader.wb`
2427
extract data from various Internet sources into a pandas DataFrame.
2528
Currently the following sources are supported:
2629

27-
- :ref:`Yahoo! Finance<remote_data.yahoo>`
28-
- :ref:`Google Finance<remote_data.google>`
2930
- :ref:`Tiingo<remote_data.tiingo>`
3031
- :ref:`Morningstar<remote_data.morningstar>`
3132
- :ref:`IEX<remote_data.iex>`
@@ -45,49 +46,6 @@ Currently the following sources are supported:
4546

4647
It should be noted, that various sources support different kinds of data, so not all sources implement the same methods and the data elements returned might also differ.
4748

48-
.. _remote_data.yahoo:
49-
50-
Yahoo! Finance
51-
==============
52-
53-
.. ipython:: python
54-
55-
import pandas_datareader.data as web
56-
import datetime
57-
start = datetime.datetime(2010, 1, 1)
58-
end = datetime.datetime(2013, 1, 27)
59-
f = web.DataReader('F', 'yahoo', start, end)
60-
f.ix['2010-01-04']
61-
62-
63-
.. ipython:: python
64-
65-
import pandas_datareader.data as web
66-
aapl = web.get_quote_yahoo('AAPL')
67-
aapl.loc['AAPL']
68-
69-
70-
.. _remote_data.google:
71-
72-
73-
Google Finance
74-
==============
75-
76-
.. warning::
77-
78-
Google'a API has become less reliable during 2017. While the google
79-
datareader often works as expected, it is not uncommon to experience
80-
a range of errors when attempting to read data, especially in bulk.
81-
82-
.. ipython:: python
83-
84-
import pandas_datareader.data as web
85-
import datetime
86-
start = datetime.datetime(2010, 1, 1)
87-
end = datetime.datetime(2013, 1, 27)
88-
f = web.DataReader('F', 'google', start, end)
89-
f.ix['2010-01-04']
90-
9149
.. _remote_data.tiingo:
9250

9351
Tiingo

docs/source/whatsnew/v0.7.0.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33
v0.7.0 (Xxxxxxx YY, 20ZZ)
44
---------------------------
55

6+
.. warning::
7+
8+
Google finance for historical price data has been immediately deprecated.
9+
610

711
Highlights include:
812

13+
- Immediate deprecation of Google finance for historical price data, as these API endpoints are no longer supported by the provider. Alternate methods are welcome via pull requests, as PDR would like to restore these features.
914

1015
.. contents:: What's new in v0.7.0
1116
:local:
@@ -42,6 +47,8 @@ Enhancements
4247

4348
Backwards incompatible API changes
4449
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50+
51+
- Deprecation of Google finance daily reader. Google retired the remaining financial data end point in June 2018. It is not possible to reliably retrieve historical price data without this endpoint. The Google daily reader will raise an `ImmediateDeprecationError` when called.
4552
- When requesting multiple symbols from a DailyReader (ex: google, yahoo, IEX)
4653
a MultiIndex DataFrame is now returned. Previously Panel or dict of DataFrames
4754
were returned. (:issue:`297`).

pandas_datareader/google/daily.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
from pandas_datareader.base import _DailyBaseReader
2-
from pandas_datareader.exceptions import UnstableAPIWarning
3-
4-
UNSTABLE_WARNING = """
5-
The Google Finance API has not been stable since late 2017. Requests seem
6-
to fail at random. Failure is especially common when bulk downloading.
7-
"""
2+
from pandas_datareader.exceptions import ImmediateDeprecationError, \
3+
DEP_ERROR_MSG
84

95

106
class GoogleDailyReader(_DailyBaseReader):
@@ -37,8 +33,7 @@ class GoogleDailyReader(_DailyBaseReader):
3733

3834
def __init__(self, symbols=None, start=None, end=None, retry_count=3,
3935
pause=0.001, session=None, chunksize=25):
40-
import warnings
41-
warnings.warn(UNSTABLE_WARNING, UnstableAPIWarning)
36+
raise ImmediateDeprecationError(DEP_ERROR_MSG.format('Google finance'))
4237
super(GoogleDailyReader, self).__init__(symbols, start, end,
4338
retry_count, pause, session,
4439
chunksize)

pandas_datareader/tests/google/test_google.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from datetime import datetime
99
from pandas_datareader.data import GoogleDailyReader
1010
from pandas_datareader._utils import RemoteDataError, SymbolWarning
11-
from pandas_datareader._testing import skip_on_exception
1211

1312
import requests
1413

@@ -20,6 +19,7 @@
2019
'ignore::pandas_datareader.exceptions.UnstableAPIWarning')
2120

2221

22+
@pytest.mark.xfail(reason="Deprecated")
2323
def assert_n_failed_equals_n_null_columns(wngs, obj, cls=SymbolWarning):
2424
all_nan_cols_dict = {}
2525

@@ -56,7 +56,7 @@ def setup_class(cls):
5656
def teardown_class(cls):
5757
del cls.locales
5858

59-
@skip_on_exception(RemoteDataError)
59+
@pytest.mark.xfail(reason="Deprecated")
6060
def test_google(self):
6161

6262
# asserts that google is minimally working and that it throws
@@ -73,6 +73,7 @@ def test_google(self):
7373
with pytest.raises(Exception):
7474
web.DataReader('NON EXISTENT TICKER', 'google', start, end)
7575

76+
@pytest.mark.xfail(reason="Deprecated")
7677
def assert_option_result(self, df):
7778
"""
7879
Validate returned quote data has expected format.
@@ -87,29 +88,29 @@ def assert_option_result(self, df):
8788
'datetime64[ns]']]
8889
tm.assert_series_equal(df.dtypes, pd.Series(dtypes, index=exp_columns))
8990

90-
@pytest.mark.xfail(reason="Google quote api is offline as of Oct 1, 2017")
91+
@pytest.mark.xfail(reason="Deprecated")
9192
def test_get_quote_string(self):
9293
df = web.get_quote_google('GOOG')
9394
assert df.loc['GOOG', 'last'] > 0.0
9495
tm.assert_index_equal(df.index, pd.Index(['GOOG']))
9596
self.assert_option_result(df)
9697

97-
@pytest.mark.xfail(reason="Google quote api is offline as of Oct 1, 2017")
98+
@pytest.mark.xfail(reason="Deprecated")
9899
def test_get_quote_stringlist(self):
99100
df = web.get_quote_google(['GOOG', 'AMZN', 'GOOG'])
100101
assert_series_equal(df.iloc[0], df.iloc[2])
101102
tm.assert_index_equal(df.index, pd.Index(['GOOG', 'AMZN', 'GOOG']))
102103
self.assert_option_result(df)
103104

104-
@skip_on_exception(RemoteDataError)
105+
@pytest.mark.xfail(reason="Deprecated")
105106
def test_get_goog_volume(self):
106107

107108
for locale in self.locales:
108109
with tm.set_locale(locale):
109110
df = web.get_data_google('GOOG').sort_index()
110111
assert df.Volume.loc['JAN-02-2015'] == 1446662
111112

112-
@skip_on_exception(RemoteDataError)
113+
@pytest.mark.xfail(reason="Deprecated")
113114
def test_get_multi1(self):
114115
for locale in self.locales:
115116
sl = ['AAPL', 'AMZN', 'GOOG']
@@ -123,18 +124,19 @@ def test_get_multi1(self):
123124
with pytest.raises(AttributeError):
124125
pan.Close()
125126

126-
@skip_on_exception(RemoteDataError)
127+
@pytest.mark.xfail(reason="Deprecated")
127128
def test_get_multi_invalid(self):
128129
sl = ['AAPL', 'AMZN', 'INVALID']
129130
data = web.get_data_google(sl, '2012')
130131
assert 'INVALID' in data.columns.levels[1]
131132

133+
@pytest.mark.xfail(reason="Deprecated")
132134
def test_get_multi_all_invalid(self):
133135
sl = ['INVALID', 'INVALID2', 'INVALID3']
134136
with pytest.raises(RemoteDataError):
135137
web.get_data_google(sl, '2012')
136138

137-
@skip_on_exception(RemoteDataError)
139+
@pytest.mark.xfail(reason="Deprecated")
138140
def test_get_multi2(self):
139141
with warnings.catch_warnings(record=True) as w:
140142
for locale in self.locales:
@@ -152,7 +154,7 @@ def test_get_multi2(self):
152154
assert result.shape == (4, 3)
153155
assert_n_failed_equals_n_null_columns(w, result)
154156

155-
@skip_on_exception(RemoteDataError)
157+
@pytest.mark.xfail(reason="Deprecated")
156158
def test_dtypes(self):
157159
# see gh-3995, gh-8980
158160
data = web.get_data_google(
@@ -165,7 +167,7 @@ def test_dtypes(self):
165167
assert np.issubdtype(data.High.dtype, np.number)
166168
assert np.issubdtype(data.Volume.dtype, np.number)
167169

168-
@skip_on_exception(RemoteDataError)
170+
@pytest.mark.xfail(reason="Deprecated")
169171
def test_unicode_date(self):
170172
# see gh-8967
171173

@@ -175,7 +177,7 @@ def test_unicode_date(self):
175177
end='JAN-27-13')
176178
assert data.index.name == 'Date'
177179

178-
@skip_on_exception(RemoteDataError)
180+
@pytest.mark.xfail(reason="Deprecated")
179181
def test_google_reader_class(self):
180182

181183
r = GoogleDailyReader('GOOG')
@@ -186,6 +188,7 @@ def test_google_reader_class(self):
186188
r = GoogleDailyReader('GOOG', session=session)
187189
assert r.session is session
188190

191+
@pytest.mark.xfail(reason="Deprecated")
189192
def test_bad_retry_count(self):
190193

191194
with pytest.raises(ValueError):

pandas_datareader/tests/test_data.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
from pandas import DataFrame
44
from pandas_datareader.data import DataReader
55
from pandas_datareader.exceptions import UnstableAPIWarning
6-
from pandas_datareader._utils import RemoteDataError
7-
from pandas_datareader._testing import skip_on_exception
86

97

108
class TestDataReader(object):
119

12-
@skip_on_exception(RemoteDataError)
10+
@pytest.mark.xfail(reason="Deprecated")
1311
def test_read_google(self):
1412
with pytest.warns(UnstableAPIWarning):
1513
gs = DataReader("GS", "google")

0 commit comments

Comments
 (0)