@@ -18,14 +18,11 @@ def test_get_cdh_e_fos(self):
18
18
assert isinstance (df , pd .DataFrame )
19
19
assert df .shape == (2 , 4 )
20
20
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 )]
23
24
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 )
29
26
exp_idx = pd .DatetimeIndex (['2006-01-01' , '2009-01-01' ],
30
27
name = 'TIME_PERIOD' )
31
28
@@ -49,6 +46,11 @@ def test_get_tourism(self):
49
46
171320408 ], dtype = float )
50
47
index = pd .date_range ('2008-01-01' , '2012-01-01' , freq = 'AS' ,
51
48
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 )
52
54
for label , values in [('Japan' , jp ), ('United States' , us )]:
53
55
expected = pd .Series (values , index = index ,
54
56
name = 'Total international arrivals' )
0 commit comments