Skip to content

Commit befbc47

Browse files
authored
TST: DataFrameGroupBy.aggregate with empty frame with MultiIndex (#43746)
1 parent 764045d commit befbc47

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
@@ -861,6 +861,16 @@ def test_groupby_aggregate_empty_key_empty_return():
861861
tm.assert_frame_equal(result, expected)
862862

863863

864+
def test_groupby_aggregate_empty_with_multiindex_frame():
865+
# GH 39178
866+
df = DataFrame(columns=["a", "b", "c"])
867+
result = df.groupby(["a", "b"]).agg(d=("c", list))
868+
expected = DataFrame(
869+
columns=["d"], index=MultiIndex([[], []], [[], []], names=["a", "b"])
870+
)
871+
tm.assert_frame_equal(result, expected)
872+
873+
864874
def test_grouby_agg_loses_results_with_as_index_false_relabel():
865875
# GH 32240: When the aggregate function relabels column names and
866876
# as_index=False is specified, the results are dropped.

0 commit comments

Comments
 (0)