@@ -57,28 +57,31 @@ def test_diff(self):
57
57
1 ), 'z' : pd .Series (1 )}).astype ('float64' )
58
58
assert_frame_equal (result , expected )
59
59
60
- @pytest .mark .parametrize ('axis' , [0 , 1 ])
61
60
@pytest .mark .parametrize ('tz' , [None , 'UTC' ])
62
- def test_diff_datetime (self , axis , tz ):
61
+ def test_diff_datetime_axis0 (self , tz ):
63
62
# GH 18578
64
63
df = DataFrame ({0 : date_range ('2010' , freq = 'D' , periods = 2 , tz = tz ),
65
64
1 : date_range ('2010' , freq = 'D' , periods = 2 , tz = tz )})
66
- if axis == 1 :
67
- if tz is None :
68
- result = df .diff (axis = axis )
69
- expected = DataFrame ({0 : pd .TimedeltaIndex (['NaT' , 'NaT' ]),
70
- 1 : pd .TimedeltaIndex (['0 days' ,
71
- '0 days' ])})
72
- assert_frame_equal (result , expected )
73
- else :
74
- with pytest .raises (NotImplementedError ):
75
- result = df .diff (axis = axis )
76
65
77
- else :
78
- result = df .diff (axis = axis )
79
- expected = DataFrame ({0 : pd .TimedeltaIndex (['NaT' , '1 days' ]),
80
- 1 : pd .TimedeltaIndex (['NaT' , '1 days' ])})
66
+ result = df .diff (axis = 0 )
67
+ expected = DataFrame ({0 : pd .TimedeltaIndex (['NaT' , '1 days' ]),
68
+ 1 : pd .TimedeltaIndex (['NaT' , '1 days' ])})
69
+ assert_frame_equal (result , expected )
70
+
71
+ @pytest .mark .parametrize ('tz' , [None , 'UTC' ])
72
+ def test_diff_datetime_axis1 (self , tz ):
73
+ # GH 18578
74
+ df = DataFrame ({0 : date_range ('2010' , freq = 'D' , periods = 2 , tz = tz ),
75
+ 1 : date_range ('2010' , freq = 'D' , periods = 2 , tz = tz )})
76
+ if tz is None :
77
+ result = df .diff (axis = 1 )
78
+ expected = DataFrame ({0 : pd .TimedeltaIndex (['NaT' , 'NaT' ]),
79
+ 1 : pd .TimedeltaIndex (['0 days' ,
80
+ '0 days' ])})
81
81
assert_frame_equal (result , expected )
82
+ else :
83
+ with pytest .raises (NotImplementedError ):
84
+ result = df .diff (axis = 1 )
82
85
83
86
def test_diff_timedelta (self ):
84
87
# GH 4533
0 commit comments