Skip to content

Commit da18fbd

Browse files
authored
COMPAT: Add forward compat for is_list_like (#520)
Pandas 0.23 moves is_list_like Add import to compat Ignore UnstableAPIWarnings in Google Swap tslib.Timestamp for Timestamp
1 parent fc62e23 commit da18fbd

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

docs/source/whatsnew/v0.7.0.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ Bug Fixes
5757
- Fix Yahoo! price data (:issue:`498`)
5858
- Added back support for Yahoo! price, dividends, and splits data for stocks
5959
and currency pairs (:issue:`487`).
60+
- Add `is_list_like` to compatibility layer to avoid failure on pandas >= 0.23 (:issue:`520`)
61+

pandas_datareader/compat/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
PANDAS_0190 = (PANDAS_VERSION >= LooseVersion('0.19.0'))
1515
PANDAS_0200 = (PANDAS_VERSION >= LooseVersion('0.20.0'))
1616
PANDAS_0210 = (PANDAS_VERSION >= LooseVersion('0.21.0'))
17+
PANDAS_0230 = (PANDAS_VERSION >= LooseVersion('0.23.0'))
1718

1819
if PANDAS_0190:
1920
from pandas.api.types import is_number
@@ -39,6 +40,12 @@ def get_filepath_or_buffer(filepath_or_buffer, encoding=None,
3940
from pandas.util.testing import assertRaisesRegexp as assert_raises_regex
4041
get_filepath_or_buffer = com.get_filepath_or_buffer
4142

43+
if PANDAS_0230:
44+
from pandas.core.dtypes.common import is_list_like
45+
else:
46+
from pandas.core.common import is_list_like
47+
48+
4249
if compat.PY3:
4350
from urllib.error import HTTPError
4451
else:

pandas_datareader/fred.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from pandas.core.common import is_list_like
1+
from pandas_datareader.compat import is_list_like
2+
23
from pandas import concat, read_csv
34

45
from pandas_datareader.base import _BaseReader

pandas_datareader/tests/google/test_google.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
import pandas.util.testing as tm
1717
from pandas.util.testing import assert_series_equal
1818

19+
pytestmark = pytest.mark.filterwarnings(
20+
'ignore::pandas_datareader.exceptions.UnstableAPIWarning')
21+
1922

2023
def assert_n_failed_equals_n_null_columns(wngs, obj, cls=SymbolWarning):
2124
all_nan_cols_dict = {}
@@ -64,8 +67,8 @@ def test_google(self):
6467
end = datetime(2013, 1, 27)
6568
for locale in self.locales:
6669
with tm.set_locale(locale):
67-
panel = web.DataReader("NYSE:F", 'google', start, end)
68-
assert panel.Close[-1] == 13.68
70+
panel = web.DataReader("NYSE:F", 'google', start, end)
71+
assert panel.Close[-1] == 13.68
6972

7073
with pytest.raises(Exception):
7174
web.DataReader('NON EXISTENT TICKER', 'google', start, end)
@@ -153,9 +156,9 @@ def test_get_multi2(self):
153156
def test_dtypes(self):
154157
# see gh-3995, gh-8980
155158
data = web.get_data_google(
156-
'NYSE:F',
157-
start='JAN-01-10',
158-
end='JAN-27-13')
159+
'NYSE:F',
160+
start='JAN-01-10',
161+
end='JAN-27-13')
159162
assert np.issubdtype(data.Open.dtype, np.number)
160163
assert np.issubdtype(data.Close.dtype, np.number)
161164
assert np.issubdtype(data.Low.dtype, np.number)
@@ -167,9 +170,9 @@ def test_unicode_date(self):
167170
# see gh-8967
168171

169172
data = web.get_data_google(
170-
'NYSE:F',
171-
start='JAN-01-10',
172-
end='JAN-27-13')
173+
'NYSE:F',
174+
start='JAN-01-10',
175+
end='JAN-27-13')
173176
assert data.index.name == 'Date'
174177

175178
@skip_on_exception(RemoteDataError)

pandas_datareader/tests/test_fred.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_fred_multi(self): # pragma: no cover
7373
received = web.DataReader(names, "fred", start, end).head(1)
7474

7575
expected = DataFrame([[217.488, 99.68746, 220.633]], columns=names,
76-
index=[pd.tslib.Timestamp('2010-01-01 00:00:00')])
76+
index=[pd.Timestamp('2010-01-01 00:00:00')])
7777
expected.index.rename('DATE', inplace=True)
7878
tm.assert_frame_equal(received, expected, check_less_precise=True)
7979

0 commit comments

Comments
 (0)