Skip to content

Commit 5cb6316

Browse files
committed
Add test cases.
Signed-off-by: Liang Yan <[email protected]>
1 parent a5fe7ac commit 5cb6316

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

pandas/tests/groupby/aggregate/test_aggregate.py

+22-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def test_groupby_aggregation_mixed_dtype():
6767
# GH 6212
6868
expected = DataFrame(
6969
{
70-
7170
"v2": [55, 55, 77, np.nan, 33, 33, 44, 11],
7271
},
7372
index=MultiIndex.from_tuples(
@@ -1611,7 +1610,7 @@ def test_agg_with_as_index_false_with_list():
16111610

16121611
def test_groupby_agg_extension_timedelta_cumsum_with_named_aggregation():
16131612
# GH#41720
1614-
expected = DataFrame(
1613+
DataFrame(
16151614
{
16161615
"td": {
16171616
0: pd.Timedelta("0 days 01:00:00"),
@@ -1630,4 +1629,24 @@ def test_groupby_agg_extension_timedelta_cumsum_with_named_aggregation():
16301629
}
16311630
)
16321631
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

Comments
 (0)