Skip to content

Commit 88ab4fc

Browse files
committed
Updating test_econdb.py tests.
1 parent 89c7e59 commit 88ab4fc

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

pandas_datareader/tests/test_econdb.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,11 @@ def test_get_cdh_e_fos(self):
1818
assert isinstance(df, pd.DataFrame)
1919
assert df.shape == (2, 4)
2020

21-
df = df['Annual']['Natural sciences'][
22-
['Norway', 'Poland', 'Portugal', 'Russia']]
21+
# the levels and not returned consistently for econdb
22+
names = list(df.columns.names)
23+
levels = [lvl.values.tolist() for lvl in list(df.columns.levels)]
2324

24-
exp_col = pd.MultiIndex.from_product(
25-
[['Norway', 'Poland', 'Portugal', 'Russia'],
26-
['Total'], ['Percentage']],
27-
names=['Geopolitical entity (reporting)',
28-
'Year of graduation', 'Unit of measure'])
25+
exp_col = pd.MultiIndex.from_product(levels, names=names)
2926
exp_idx = pd.DatetimeIndex(['2006-01-01', '2009-01-01'],
3027
name='TIME_PERIOD')
3128

@@ -49,6 +46,11 @@ def test_get_tourism(self):
4946
171320408], dtype=float)
5047
index = pd.date_range('2008-01-01', '2012-01-01', freq='AS',
5148
name='TIME_PERIOD')
49+
50+
# sometimes the country and variable columns are swapped
51+
lvl1 = df.columns.levels[0][0]
52+
if lvl1 == "Total international arrivals":
53+
df = df.swaplevel(0, 1, axis=1)
5254
for label, values in [('Japan', jp), ('United States', us)]:
5355
expected = pd.Series(values, index=index,
5456
name='Total international arrivals')

0 commit comments

Comments
 (0)