Skip to content

Commit 62929f9

Browse files
committed
MAINT: Fixes for Python 3.9 and older pandas
1 parent 489ea52 commit 62929f9

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

pandas_datareader/fred.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,13 @@ def fetch_data(url, name):
5858
) from exc
5959
raise
6060

61+
try:
62+
data = [fetch_data(url, n) for url, n in zip(urls, names, strict=True)]
63+
except TypeError:
64+
# Python 3.9 only
65+
data = [fetch_data(url, n) for url, n in zip(urls, names)] # noqa: B905
6166
df = concat(
62-
[fetch_data(url, n) for url, n in zip(urls, names, strict=True)],
67+
data,
6368
axis=1,
6469
join="outer",
6570
)

pandas_datareader/tests/test_bankofcanada.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,15 @@ def check_bankofcanada_inverted(self, code):
4141
date.today() - timedelta(days=30),
4242
date.today(),
4343
)
44-
45-
pairs = zip(
46-
(1 / df)[symbol].tolist(), df_i[symbol_inverted].tolist(), strict=True
47-
)
44+
try:
45+
pairs = zip(
46+
(1 / df)[symbol].tolist(), df_i[symbol_inverted].tolist(), strict=True
47+
)
48+
except TypeError:
49+
# Python 3.9 only
50+
pairs = zip( # noqa: B905
51+
(1 / df)[symbol].tolist(), df_i[symbol_inverted].tolist()
52+
)
4853
assert all(a - b < 0.01 for a, b in pairs)
4954

5055
def test_bankofcanada_usd_count(self):

pandas_datareader/tests/test_famafrench.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ def test_get_available_datasets(self):
3232

3333
def test_index(self):
3434
ff = web.DataReader("F-F_Research_Data_Factors", "famafrench")
35-
assert ff[0].index.freq.name == "ME"
36-
assert ff[1].index.freq.name == "YE-DEC"
35+
# M is for legacy pandas < 2
36+
assert ff[0].index.freq.name in ("ME", "M")
37+
# A-DEC is for legacy pandas < 2
38+
assert ff[1].index.freq.name in ("YE-DEC", "A-DEC")
3739

3840
def test_f_f_research(self):
3941
results = web.DataReader(

pandas_datareader/tests/test_stooq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ def test_stooq_googl():
4343

4444

4545
def test_get_data_ibm():
46-
f = get_data_stooq("IBM.UK")
46+
f = get_data_stooq("IBM.DE")
4747
assert f.shape[0] > 0

0 commit comments

Comments
 (0)