Skip to content

Commit 63fa128

Browse files
author
Jon M. Mease
committed
Trap warning introduced by GH14432 in test_groupby_multi_categorical_as_index
1 parent dd8cba2 commit 63fa128

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pandas/tests/test_groupby.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -6778,9 +6778,19 @@ def test_groupby_multi_categorical_as_index(self):
67786778
'B': [101.0, nan, nan, 205.0, nan, nan]},
67796779
columns=['cat', 'A', 'B'])
67806780

6781+
group_columns = ['cat', 'A']
6782+
67816783
for name in [None, 'X', 'B', 'cat']:
67826784
df.index = Index(list("abc"), name=name)
6783-
result = df.groupby(['cat', 'A'], as_index=False).sum()
6785+
6786+
if name in group_columns and name in df.index.names:
6787+
with tm.assert_produces_warning(FutureWarning,
6788+
check_stacklevel=False):
6789+
result = df.groupby(group_columns, as_index=False).sum()
6790+
6791+
else:
6792+
result = df.groupby(group_columns, as_index=False).sum()
6793+
67846794
tm.assert_frame_equal(result, expected, check_index_type=True)
67856795

67866796
def test_groupby_preserve_categorical_dtype(self):

0 commit comments

Comments
 (0)