@@ -57,28 +57,31 @@ def test_diff(self):
5757 1 ), 'z' : pd .Series (1 )}).astype ('float64' )
5858 assert_frame_equal (result , expected )
5959
60- @pytest .mark .parametrize ('axis' , [0 , 1 ])
6160 @pytest .mark .parametrize ('tz' , [None , 'UTC' ])
62- def test_diff_datetime (self , axis , tz ):
61+ def test_diff_datetime_axis0 (self , tz ):
6362 # GH 18578
6463 df = DataFrame ({0 : date_range ('2010' , freq = 'D' , periods = 2 , tz = tz ),
6564 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 )
7665
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' ])})
8181 assert_frame_equal (result , expected )
82+ else :
83+ with pytest .raises (NotImplementedError ):
84+ result = df .diff (axis = 1 )
8285
8386 def test_diff_timedelta (self ):
8487 # GH 4533
0 commit comments