1
+ import nose
1
2
import sys
2
3
3
4
import numpy as np
@@ -11,13 +12,14 @@ class TestEurostat(tm.TestCase):
11
12
def setUp (self ):
12
13
13
14
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" )
16
17
17
18
def test_get_cdh_e_fos (self ):
18
19
# Employed doctorate holders in non managerial and non professional
19
20
# 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' ),
21
23
end = pd .Timestamp ('2010-01-01' ))
22
24
23
25
self .assertTrue (isinstance (df , pd .DataFrame ))
@@ -26,10 +28,11 @@ def test_get_cdh_e_fos(self):
26
28
df = df ['Percentage' ]['Total' ]['Natural sciences' ]
27
29
df = df [['Norway' , 'Poland' , 'Portugal' , 'Russia' ]]
28
30
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' ]],
31
33
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' )
33
36
34
37
values = np .array ([[25.49 , np .nan , 39.05 , np .nan ],
35
38
[20.38 , 25.1 , 27.77 , 38.1 ]])
@@ -38,33 +41,37 @@ def test_get_cdh_e_fos(self):
38
41
39
42
def test_get_sts_cobp_a (self ):
40
43
# 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' ),
42
46
end = pd .Timestamp ('2013-01-01' ))
43
47
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 )
62
69
63
70
for expected in [ne , uk ]:
64
71
result = df [expected .name ]
65
72
tm .assert_series_equal (result , expected )
66
73
67
74
68
75
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 )
0 commit comments