@@ -67,7 +67,6 @@ def test_groupby_aggregation_mixed_dtype():
67
67
# GH 6212
68
68
expected = DataFrame (
69
69
{
70
-
71
70
"v2" : [55 , 55 , 77 , np .nan , 33 , 33 , 44 , 11 ],
72
71
},
73
72
index = MultiIndex .from_tuples (
@@ -1611,7 +1610,7 @@ def test_agg_with_as_index_false_with_list():
1611
1610
1612
1611
def test_groupby_agg_extension_timedelta_cumsum_with_named_aggregation ():
1613
1612
# GH#41720
1614
- expected = DataFrame (
1613
+ DataFrame (
1615
1614
{
1616
1615
"td" : {
1617
1616
0 : pd .Timedelta ("0 days 01:00:00" ),
@@ -1630,4 +1629,24 @@ def test_groupby_agg_extension_timedelta_cumsum_with_named_aggregation():
1630
1629
}
1631
1630
)
1632
1631
gb = df .groupby ("grps" )
1633
- result = gb .agg (td = ("td" , "cumsum" ))
1632
+ gb .agg (td = ("td" , "cumsum" ))
1633
+
1634
+
1635
+ @skip_if_no_pyarrow
1636
+ def test_agg_arrow_type ():
1637
+ df = DataFrame .from_dict (
1638
+ {
1639
+ "category" : ["A" ] * 10 + ["B" ] * 10 ,
1640
+ "bool_numpy" : [True ] * 5 + [False ] * 5 + [True ] * 5 + [False ] * 5 ,
1641
+ }
1642
+ )
1643
+ df ["bool_arrow" ] = df ["bool_numpy" ].astype ("bool[pyarrow]" )
1644
+ result = df .groupby ("category" ).agg (lambda x : x .sum () / x .count ())
1645
+ expected = DataFrame (
1646
+ {
1647
+ "bool_numpy" : [0.5 , 0.5 ],
1648
+ "bool_arrow" : Series ([0.5 , 0.5 ]).astype ("double[pyarrow]" ).values ,
1649
+ },
1650
+ index = Index (["A" , "B" ], name = "category" ),
1651
+ )
1652
+ tm .assert_frame_equal (result , expected )
0 commit comments