Skip to content

Commit

Permalink
TST: Check index when grouping all columns of empty DF (#32464) (#48067)
Browse files Browse the repository at this point in the history
TST: Check MultiIndex when grouping by all columns of an empty DF (#32464)

Co-authored-by: Richard Shadrach
    <45562402+rhshadrach@users.noreply.github.com>

Co-authored-by: Richard Shadrach <45562402+rhshadrach@users.noreply.github.com>
  • Loading branch information
YagoGG and rhshadrach authored Aug 15, 2022
1 parent 06dd5da commit c70f9b9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pandas/tests/groupby/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -1588,3 +1588,15 @@ def test_corrwith_with_1_axis():
)
expected = Series([np.nan] * 6, index=index)
tm.assert_series_equal(result, expected)


def test_multiindex_group_all_columns_when_empty(groupby_func):
# GH 32464
df = DataFrame({"a": [], "b": [], "c": []}).set_index(["a", "b", "c"])
gb = df.groupby(["a", "b", "c"])
method = getattr(gb, groupby_func)
args = get_groupby_method_args(groupby_func, df)

result = method(*args).index
expected = df.index
tm.assert_index_equal(result, expected)

0 comments on commit c70f9b9

Please sign in to comment.