Skip to content

Commit 14991df

Browse files
talukder-sowrovLakmal Pinnaduwage
and
Lakmal Pinnaduwage
authored
TST: Add test for groupby aggregatation with nested dictionary (#50079)
Co-authored-by: Lakmal Pinnaduwage <[email protected]>
1 parent 4eb4729 commit 14991df

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/tests/groupby/aggregate/test_aggregate.py

+10
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,16 @@ def test_groupby_agg_coercing_bools():
468468
tm.assert_series_equal(result, expected)
469469

470470

471+
def test_groupby_agg_dict_with_getitem():
472+
# issue 25471
473+
dat = DataFrame({"A": ["A", "A", "B", "B", "B"], "B": [1, 2, 1, 1, 2]})
474+
result = dat.groupby("A")[["B"]].agg({"B": "sum"})
475+
476+
expected = DataFrame({"B": [3, 4]}, index=["A", "B"]).rename_axis("A", axis=0)
477+
478+
tm.assert_frame_equal(result, expected)
479+
480+
471481
@pytest.mark.parametrize(
472482
"op",
473483
[

0 commit comments

Comments
 (0)