Skip to content

Commit 6c9ceae

Browse files
committed
Merge pull request #163 from jtkiley/euro-oecd-tests
FIX Eurostat and OECD tests that fail.
2 parents c882161 + 4ed974e commit 6c9ceae

File tree

3 files changed

+55
-37
lines changed

3 files changed

+55
-37
lines changed

pandas_datareader/compat/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
# flake8: noqa
12
from io import BytesIO
Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import nose
12
import sys
23

34
import numpy as np
@@ -11,13 +12,14 @@ class TestEurostat(tm.TestCase):
1112
def setUp(self):
1213

1314
if sys.version_info < (2, 7, 0):
14-
import nose
15-
raise nose.SkipTest("Doesn't support Python 2.6 because of ElementTree incompat")
15+
raise nose.SkipTest("Doesn't support Python 2.6 because of"
16+
"ElementTree incompat")
1617

1718
def test_get_cdh_e_fos(self):
1819
# Employed doctorate holders in non managerial and non professional
1920
# occupations by fields of science (%)
20-
df = web.DataReader('cdh_e_fos', 'eurostat', start=pd.Timestamp('2005-01-01'),
21+
df = web.DataReader('cdh_e_fos', 'eurostat',
22+
start=pd.Timestamp('2005-01-01'),
2123
end=pd.Timestamp('2010-01-01'))
2224

2325
self.assertTrue(isinstance(df, pd.DataFrame))
@@ -26,10 +28,11 @@ def test_get_cdh_e_fos(self):
2628
df = df['Percentage']['Total']['Natural sciences']
2729
df = df[['Norway', 'Poland', 'Portugal', 'Russia']]
2830

29-
exp_col = pd.MultiIndex.from_product([['Norway', 'Poland', 'Portugal', 'Russia'],
30-
['Annual']],
31+
exp_col = pd.MultiIndex.from_product([['Norway', 'Poland', 'Portugal',
32+
'Russia'], ['Annual']],
3133
names=['GEO', 'FREQ'])
32-
exp_idx = pd.DatetimeIndex(['2006-01-01', '2009-01-01'], name='TIME_PERIOD')
34+
exp_idx = pd.DatetimeIndex(['2006-01-01', '2009-01-01'],
35+
name='TIME_PERIOD')
3336

3437
values = np.array([[25.49, np.nan, 39.05, np.nan],
3538
[20.38, 25.1, 27.77, 38.1]])
@@ -38,33 +41,37 @@ def test_get_cdh_e_fos(self):
3841

3942
def test_get_sts_cobp_a(self):
4043
# Building permits - annual data (2010 = 100)
41-
df = web.DataReader('sts_cobp_a', 'eurostat', start=pd.Timestamp('1992-01-01'),
44+
df = web.DataReader('sts_cobp_a', 'eurostat',
45+
start=pd.Timestamp('1992-01-01'),
4246
end=pd.Timestamp('2013-01-01'))
4347

44-
idx = pd.date_range('1992-01-01', '2013-01-01', freq='AS', name='TIME_PERIOD')
45-
ne = pd.Series([np.nan, np.nan, np.nan, 144.53, 136.97, 180.02, 198.36,
46-
215.12, 200.05, 186.46, 127.33, 130.67, 143.26, 147.83,
47-
176.69, 227.36, 199.45, 128.49, 100.0, 113.83, 89.33, 77.57],
48-
name=('Building permits - m2 of useful floor area',
49-
'Gross data',
50-
'Non-residential buildings, except office buildings',
51-
'Netherlands', 'Annual'),
52-
index=idx)
53-
54-
uk = pd.Series([np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, 120.37,
55-
115.93, 112.53, 113.32, 110.18, 112.14, 119.06, 112.66,
56-
113.05, 121.8, 113.97, 105.88, 100.0, 98.56, 103.69, 81.32],
57-
name=('Building permits - m2 of useful floor area',
58-
'Gross data',
59-
'Non-residential buildings, except office buildings',
60-
'United Kingdom', 'Annual'),
61-
index=idx)
48+
idx = pd.date_range('1992-01-01', '2013-01-01', freq='AS',
49+
name='TIME_PERIOD')
50+
ne_name = ('Building permits - m2 of useful floor area',
51+
'Not seasonally adjusted data',
52+
'Non-residential buildings, except office buildings',
53+
'Netherlands', 'Annual')
54+
ne_values = [np.nan, np.nan, np.nan, 144.53, 136.97, 180.02, 198.36,
55+
215.12, 200.05, 186.46, 127.33, 130.67, 143.26, 147.83,
56+
176.69, 227.36, 199.45, 128.49, 100.0, 113.83, 89.33,
57+
77.57]
58+
ne = pd.Series(ne_values, name=ne_name, index=idx)
59+
60+
uk_name = ('Building permits - m2 of useful floor area',
61+
'Not seasonally adjusted data',
62+
'Non-residential buildings, except office buildings',
63+
'United Kingdom', 'Annual')
64+
uk_values = [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, 120.37,
65+
115.93, 112.53, 113.32, 110.18, 112.14, 119.06, 112.66,
66+
113.05, 121.8, 113.97, 105.88, 100.0, 98.56, 103.69,
67+
81.32]
68+
uk = pd.Series(uk_values, name=uk_name, index=idx)
6269

6370
for expected in [ne, uk]:
6471
result = df[expected.name]
6572
tm.assert_series_equal(result, expected)
6673

6774

6875
if __name__ == '__main__':
69-
import nose
70-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'], exit=False)
76+
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
77+
exit=False)

pandas_datareader/tests/test_oecd.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import nose
2+
13
from datetime import datetime
24
import numpy as np
35
import pandas as pd
@@ -46,21 +48,29 @@ def test_get_un_den(self):
4648
11.96023574, 11.48458378, 11.56435375, 11.91022276, 11.79401904,
4749
11.38345975, 11.32948829, 11.07884758]
4850

49-
index = pd.date_range('1960-01-01', '2012-01-01', freq='AS', name='Time')
50-
for label, values in [('Australia', au), ('Japan', jp), ('United States', us)]:
51+
index = pd.date_range('1960-01-01', '2012-01-01', freq='AS',
52+
name='Time')
53+
for label, values in [('Australia', au), ('Japan', jp),
54+
('United States', us)]:
5155
expected = pd.Series(values, index=index, name=label)
5256
tm.assert_series_equal(df[label], expected)
5357

5458
def test_get_tourism(self):
55-
df = web.DataReader('TOURISM_INBOUND', 'oecd', start=datetime(2005, 1, 1),
59+
df = web.DataReader('TOURISM_INBOUND', 'oecd',
60+
start=datetime(2008, 1, 1),
5661
end=datetime(2012, 1, 1))
5762

58-
jp = np.array([6728.0, 7334.0, 8347.0, 8351.0, 6790.0, 8611.0, 6219.0, 8368.0], dtype=float)
59-
us = np.array([np.nan, 183178.0, 175142.0, 175632.0, 160359.0, 162269.0, 164672.0, 171630.0], dtype=float)
60-
index = pd.date_range('2005-01-01', '2012-01-01', freq='AS', name='Year')
63+
jp = np.array([8351000, 6790000, 8611000, 6219000,
64+
8368000], dtype=float)
65+
us = np.array([175702309, 160507417, 164079732, 167600277,
66+
171320408], dtype=float)
67+
index = pd.date_range('2008-01-01', '2012-01-01', freq='AS',
68+
name='Year')
6169
for label, values in [('Japan', jp), ('United States', us)]:
62-
expected = pd.Series(values, index=index, name='Total international arrivals')
63-
tm.assert_series_equal(df[label]['Total international arrivals'], expected)
70+
expected = pd.Series(values, index=index,
71+
name='Total international arrivals')
72+
tm.assert_series_equal(df[label]['Total international arrivals'],
73+
expected)
6474

6575
def test_oecd_invalid_symbol(self):
6676
with tm.assertRaises(RemoteDataError):
@@ -71,5 +81,5 @@ def test_oecd_invalid_symbol(self):
7181

7282

7383
if __name__ == '__main__':
74-
import nose
75-
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'], exit=False)
84+
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
85+
exit=False)

0 commit comments

Comments
 (0)