Skip to content

Commit

Permalink
TST added test for groupby agg on mulitlevel column (pandas-dev#29772)
Browse files Browse the repository at this point in the history
  • Loading branch information
prakhar987 committed Nov 26, 2019
1 parent db60ab6 commit 5a5aabd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pandas/tests/groupby/aggregate/test_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ def test_groupby_aggregation_mixed_dtype():
tm.assert_frame_equal(result, expected)


def test_groupby_aggregation_multi_level_column():
lst = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, np.nan, 6], [4, 5, 6, 7]]
df = pd.DataFrame(np.array(lst), columns=[["a", "a", "b", "b"], [0, 1, 0, 1]])

result = df.groupby(level=1, axis=1).sum()

lst = [[4, 6], [6, 8], [3, 10], [10, 12]]
expected = pd.DataFrame(np.array(lst), dtype="float64")

tm.assert_frame_equal(result, expected)


def test_agg_apply_corner(ts, tsframe):
# nothing to group, all NA
grouped = ts.groupby(ts * np.nan)
Expand Down

0 comments on commit 5a5aabd

Please sign in to comment.