We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d338b94 commit d7328d3Copy full SHA for d7328d3
pandas/tests/groupby/aggregate/test_aggregate.py
@@ -92,6 +92,25 @@ def test_groupby_aggregation_mixed_dtype():
92
tm.assert_frame_equal(result, expected)
93
94
95
+def test_groupby_aggregation_multi_level_column():
96
+ # GH 29772
97
+ lst = [
98
+ [True, True, True, False],
99
+ [True, False, np.nan, False],
100
+ [True, True, np.nan, False],
101
102
+ ]
103
+ df = pd.DataFrame(
104
+ data=lst,
105
+ columns=pd.MultiIndex.from_tuples([("A", 0), ("A", 1), ("B", 0), ("B", 1)]),
106
+ )
107
+
108
+ result = df.groupby(level=1, axis=1).sum()
109
+ expected = pd.DataFrame({0: [2.0, 1, 1, 1], 1: [1, 0, 1, 1]})
110
111
+ tm.assert_frame_equal(result, expected)
112
113
114
def test_agg_apply_corner(ts, tsframe):
115
# nothing to group, all NA
116
grouped = ts.groupby(ts * np.nan)
0 commit comments