Skip to content

Commit

Permalink
Merge pull request #404 from pydata/fix_050
Browse files Browse the repository at this point in the history
Fix various failures in tests
  • Loading branch information
davidastephens authored Oct 8, 2017
2 parents 331e389 + 4dfafd7 commit edc8a8d
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 17 deletions.
10 changes: 6 additions & 4 deletions docs/source/remote_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,13 @@ Google Finance Quotes

The GoogleQuotesReader class allows to get quotes data from Google Finance.

.. ipython:: python
OFFLINE AS OF OCT 1, 2017

import pandas_datareader.data as web
q = web.get_quote_google(['AMZN', 'GOOG'])
q
.. .. ipython:: python
.. import pandas_datareader.data as web
.. q = web.get_quote_google(['AMZN', 'GOOG'])
.. q
.. _remote_data.google_options:

Expand Down
2 changes: 1 addition & 1 deletion pandas_datareader/google/daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GoogleDailyReader(_DailyBaseReader):

@property
def url(self):
return 'http://www.google.com/finance/historical'
return 'http://finance.google.com/finance/historical'

def _get_params(self, symbol):
params = {
Expand Down
4 changes: 3 additions & 1 deletion pandas_datareader/google/quotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

class GoogleQuotesReader(_BaseReader):

"""Get current google quote"""
"""Get current google quote
WARNING: OFFLINE AS OF OCT 1, 2017
"""

@property
def url(self):
Expand Down
16 changes: 12 additions & 4 deletions pandas_datareader/tests/google/test_google.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_google(self):

for locale in self.locales:
with tm.set_locale(locale):
panel = web.DataReader("F", 'google', start, end)
panel = web.DataReader("NYSE:F", 'google', start, end)
assert panel.Close[-1] == 13.68

with pytest.raises(Exception):
Expand All @@ -82,12 +82,14 @@ def assert_option_result(self, df):
tm.assert_series_equal(df.dtypes, pd.Series(dtypes, index=exp_columns))

def test_get_quote_string(self):
pytest.skip("Google quote api is offline as of Oct 1, 2017")
df = web.get_quote_google('GOOG')
assert df.loc['GOOG', 'last'] > 0.0
tm.assert_index_equal(df.index, pd.Index(['GOOG']))
self.assert_option_result(df)

def test_get_quote_stringlist(self):
pytest.skip("Google quote api is offline as of Oct 1, 2017")
df = web.get_quote_google(['GOOG', 'AMZN', 'GOOG'])
assert_series_equal(df.iloc[0], df.iloc[2])
tm.assert_index_equal(df.index, pd.Index(['GOOG', 'AMZN', 'GOOG']))
Expand Down Expand Up @@ -143,7 +145,10 @@ def test_get_multi2(self):

def test_dtypes(self):
# see gh-3995, gh-8980
data = web.get_data_google('F', start='JAN-01-10', end='JAN-27-13')
data = web.get_data_google(
'NYSE:F',
start='JAN-01-10',
end='JAN-27-13')
assert np.issubdtype(data.Open.dtype, np.number)
assert np.issubdtype(data.Close.dtype, np.number)
assert np.issubdtype(data.Low.dtype, np.number)
Expand All @@ -152,7 +157,10 @@ def test_dtypes(self):

def test_unicode_date(self):
# see gh-8967
data = web.get_data_google('F', start='JAN-01-10', end='JAN-27-13')
data = web.get_data_google(
'NYSE:F',
start='JAN-01-10',
end='JAN-27-13')
assert data.index.name == 'Date'

def test_google_reader_class(self):
Expand All @@ -167,4 +175,4 @@ def test_google_reader_class(self):
def test_bad_retry_count(self):

with pytest.raises(ValueError):
web.get_data_google('F', retry_count=-1)
web.get_data_google('NYSE:F', retry_count=-1)
8 changes: 4 additions & 4 deletions pandas_datareader/tests/test_famafrench.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def test_f_f_research(self):

exp = pd.DataFrame({'Mkt-RF': [-3.36, 3.4, 6.31, 2., -7.89, -5.56,
6.93, -4.77, 9.54, 3.88, 0.6, 6.82],
'SMB': [0.37, 1.19, 1.49, 4.99, 0.0, -2.01, 0.21,
-2.99, 3.92, 1.14, 3.68, 0.68],
'HML': [0.3, 3.18, 2.15, 2.83, -2.41, -4.52, -0.21,
-1.96, -3.12, -2.52, -0.91, 3.78],
'SMB': [0.38, 1.2, 1.42, 4.98, 0.05, -1.97, 0.16,
-3.00, 3.92, 1.15, 3.70, 0.7],
'HML': [0.31, 3.16, 2.1, 2.81, -2.38, -4.5, -0.27,
-1.95, -3.12, -2.59, -0.9, 3.81],
'RF': [0., 0., 0.01, 0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01, 0.01]},
index=pd.period_range('2010-01-01', '2010-12-01',
Expand Down
4 changes: 2 additions & 2 deletions pandas_datareader/tests/yahoo/test_yahoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def setup_class(cls):
def test_yahoo(self):
# Asserts that yahoo is minimally working
start = datetime(2010, 1, 1)
end = datetime(2013, 1, 27)
end = datetime(2013, 1, 25)

assert web.DataReader('F', 'yahoo', start, end)['Close'][-1] == 13.68

Expand Down Expand Up @@ -205,7 +205,7 @@ def test_yahoo_reader_class(self):
r = YahooDailyReader('GOOG')
df = r.read()

assert df.Volume.loc['JAN-02-2015'] == 1447500
assert df.Volume.loc['JAN-02-2015'] == 1447600

session = requests.Session()

Expand Down
2 changes: 1 addition & 1 deletion pandas_datareader/yahoo/daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def read(self):
df['Ret_Index'] = _calc_return_index(df['Adj Close'])
if self.adjust_price:
df = _adjust_prices(df)
return df.sort_index()
return df.sort_index().dropna(how='all')
finally:
self.close()

Expand Down

0 comments on commit edc8a8d

Please sign in to comment.