10
10
11
11
from pandas import DataFrame , Series , Index , Timestamp , DatetimeIndex
12
12
import pandas as pd
13
- import pandas .core . datetools as datetools
13
+ import pandas .tseries . offsets as offsets
14
14
15
15
from pandas .util .testing import (assert_almost_equal ,
16
16
assert_series_equal ,
@@ -136,14 +136,14 @@ def test_shift(self):
136
136
assert_frame_equal (unshifted , self .tsframe )
137
137
138
138
# shift by DateOffset
139
- shiftedFrame = self .tsframe .shift (5 , freq = datetools .BDay ())
139
+ shiftedFrame = self .tsframe .shift (5 , freq = offsets .BDay ())
140
140
self .assertEqual (len (shiftedFrame ), len (self .tsframe ))
141
141
142
142
shiftedFrame2 = self .tsframe .shift (5 , freq = 'B' )
143
143
assert_frame_equal (shiftedFrame , shiftedFrame2 )
144
144
145
145
d = self .tsframe .index [0 ]
146
- shifted_d = d + datetools .BDay (5 )
146
+ shifted_d = d + offsets .BDay (5 )
147
147
assert_series_equal (self .tsframe .xs (d ),
148
148
shiftedFrame .xs (shifted_d ), check_names = False )
149
149
@@ -160,7 +160,7 @@ def test_shift(self):
160
160
ps .ix [:- 1 , 0 ].values )
161
161
162
162
shifted2 = ps .shift (1 , 'B' )
163
- shifted3 = ps .shift (1 , datetools . bday )
163
+ shifted3 = ps .shift (1 , offsets . BDay () )
164
164
assert_frame_equal (shifted2 , shifted3 )
165
165
assert_frame_equal (ps , shifted2 .shift (- 1 , 'B' ))
166
166
@@ -222,7 +222,7 @@ def test_tshift(self):
222
222
shifted2 = ps .tshift (freq = 'B' )
223
223
assert_frame_equal (shifted , shifted2 )
224
224
225
- shifted3 = ps .tshift (freq = datetools . bday )
225
+ shifted3 = ps .tshift (freq = offsets . BDay () )
226
226
assert_frame_equal (shifted , shifted3 )
227
227
228
228
assertRaisesRegexp (ValueError , 'does not match' , ps .tshift , freq = 'M' )
@@ -297,7 +297,7 @@ def test_truncate_copy(self):
297
297
self .assertFalse ((self .tsframe .values [5 :11 ] == 5 ).any ())
298
298
299
299
def test_asfreq (self ):
300
- offset_monthly = self .tsframe .asfreq (datetools . bmonthEnd )
300
+ offset_monthly = self .tsframe .asfreq (offsets . BMonthEnd () )
301
301
rule_monthly = self .tsframe .asfreq ('BM' )
302
302
303
303
assert_almost_equal (offset_monthly ['A' ], rule_monthly ['A' ])
@@ -365,3 +365,9 @@ def test_operation_on_NaT(self):
365
365
res = df .max ()
366
366
exp = pd .Series ([pd .NaT ], index = ["foo" ])
367
367
tm .assert_series_equal (res , exp )
368
+
369
+
370
+ if __name__ == '__main__' :
371
+ import nose
372
+ nose .runmodule (argv = [__file__ , '-vvs' , '-x' , '--pdb' , '--pdb-failure' ],
373
+ exit = False )
0 commit comments