@@ -36,11 +36,18 @@ def test_groupby_extension_agg(self, as_index, data_for_grouping):
36
36
def test_groupby_agg_extension (self , data_for_grouping ):
37
37
# GH#38980 groupby agg on extension type fails for non-numeric types
38
38
df = pd .DataFrame ({"A" : [1 , 1 , 2 , 2 , 3 , 3 , 1 , 4 ], "B" : data_for_grouping })
39
- result = df .groupby ("A" ).agg ({"B" : "first" }).B .array
40
39
41
- expected = df ["B" ].iloc [[0 , 2 , 4 , 7 ]].array
40
+ expected = df .iloc [[0 , 2 , 4 , 7 ]]
41
+ expected = expected .set_index ("A" )
42
42
43
- self .assert_extension_array_equal (result , expected )
43
+ result = df .groupby ("A" ).agg ({"B" : "first" })
44
+ self .assert_frame_equal (result , expected )
45
+
46
+ result = df .groupby ("A" ).agg ("first" )
47
+ self .assert_frame_equal (result , expected )
48
+
49
+ result = df .groupby ("A" ).first ()
50
+ self .assert_frame_equal (result , expected )
44
51
45
52
def test_groupby_extension_no_sort (self , data_for_grouping ):
46
53
df = pd .DataFrame ({"A" : [1 , 1 , 2 , 2 , 3 , 3 , 1 , 4 ], "B" : data_for_grouping })
0 commit comments