@@ -323,15 +323,22 @@ def test_transform_transformation_func(transformation_func):
323323 {
324324 "A" : ["foo" , "foo" , "foo" , "foo" , "bar" , "bar" , "baz" ],
325325 "B" : [1 , 2 , np .nan , 3 , 3 , np .nan , 4 ],
326- }
326+ },
327+ index = pd .date_range ("2020-01-01" , "2020-01-07" ),
327328 )
328329
329- if transformation_func in [ "pad" , "backfill" , "tshift" , " cumcount"] :
330- # These transformation functions are not yet covered in this test
331- pytest . xfail ( "See GH 31269" )
330+ if transformation_func == " cumcount" :
331+ test_op = lambda x : x . transform ( "cumcount" )
332+ mock_op = lambda x : Series ( range ( len ( x )), x . index )
332333 elif transformation_func == "fillna" :
333334 test_op = lambda x : x .transform ("fillna" , value = 0 )
334335 mock_op = lambda x : x .fillna (value = 0 )
336+ elif transformation_func == "tshift" :
337+ msg = (
338+ "Current behavior of groupby.tshift is inconsistent with other "
339+ "transformations. See GH34452 for more details"
340+ )
341+ pytest .xfail (msg )
335342 else :
336343 test_op = lambda x : x .transform (transformation_func )
337344 mock_op = lambda x : getattr (x , transformation_func )()
@@ -340,7 +347,10 @@ def test_transform_transformation_func(transformation_func):
340347 groups = [df [["B" ]].iloc [:4 ], df [["B" ]].iloc [4 :6 ], df [["B" ]].iloc [6 :]]
341348 expected = concat ([mock_op (g ) for g in groups ])
342349
343- tm .assert_frame_equal (result , expected )
350+ if transformation_func == "cumcount" :
351+ tm .assert_series_equal (result , expected )
352+ else :
353+ tm .assert_frame_equal (result , expected )
344354
345355
346356def test_transform_select_columns (df ):
0 commit comments