Skip to content

Commit 2db934e

Browse files
authored
Added a test for the groupby MultiIndex with codes (#59102)
1 parent d465645 commit 2db934e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/groupby/test_groupby.py

+11
Original file line numberDiff line numberDiff line change
@@ -2985,3 +2985,14 @@ def test_groupby_agg_namedagg_with_duplicate_columns():
29852985
)
29862986

29872987
tm.assert_frame_equal(result, expected)
2988+
2989+
2990+
def test_groupby_multi_index_codes():
2991+
# GH#54347
2992+
df = DataFrame(
2993+
{"A": [1, 2, 3, 4], "B": [1, float("nan"), 2, float("nan")], "C": [2, 4, 6, 8]}
2994+
)
2995+
df_grouped = df.groupby(["A", "B"], dropna=False).sum()
2996+
2997+
index = df_grouped.index
2998+
tm.assert_index_equal(index, MultiIndex.from_frame(index.to_frame()))

0 commit comments

Comments
 (0)