Skip to content

Commit 74adfd6

Browse files
authored
TST: Groupby.agg with mutliples ignores as_index False (#52395)
groupby.agg-with-mutliples-ignores-as_index=False-after-subset-to-a-single-column
1 parent 76670db commit 74adfd6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/tests/groupby/aggregate/test_aggregate.py

+9
Original file line numberDiff line numberDiff line change
@@ -1577,3 +1577,12 @@ def test_agg_groupings_selection():
15771577
)
15781578
expected = DataFrame({"b": [6, 4], "c": [11, 7]}, index=index)
15791579
tm.assert_frame_equal(result, expected)
1580+
1581+
1582+
def test_agg_multiple_with_as_index_false_subset_to_a_single_column():
1583+
# GH#50724
1584+
df = DataFrame({"a": [1, 1, 2], "b": [3, 4, 5]})
1585+
gb = df.groupby("a", as_index=False)["b"]
1586+
result = gb.agg(["sum", "mean"])
1587+
expected = DataFrame({"a": [1, 2], "sum": [7, 5], "mean": [3.5, 5.0]})
1588+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)