Skip to content

Commit c30fa2b

Browse files
author
Jon M. Mease
committed
Trap warning introduced by GH14432 in test_groupby_multi_categorical_as_index
1 parent 73bc6cf commit c30fa2b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pandas/tests/groupby/test_categorical.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,19 @@ def test_groupby_multi_categorical_as_index(self):
349349
'B': [101.0, nan, nan, 205.0, nan, nan]},
350350
columns=['cat', 'A', 'B'])
351351

352+
group_columns = ['cat', 'A']
353+
352354
for name in [None, 'X', 'B', 'cat']:
353355
df.index = Index(list("abc"), name=name)
354-
result = df.groupby(['cat', 'A'], as_index=False).sum()
356+
357+
if name in group_columns and name in df.index.names:
358+
with tm.assert_produces_warning(FutureWarning,
359+
check_stacklevel=False):
360+
result = df.groupby(group_columns, as_index=False).sum()
361+
362+
else:
363+
result = df.groupby(group_columns, as_index=False).sum()
364+
355365
tm.assert_frame_equal(result, expected, check_index_type=True)
356366

357367
def test_groupby_preserve_categorical_dtype(self):

0 commit comments

Comments
 (0)