From c30fa2bad158ca6735ea1002b420cc6e9b7aca69 Mon Sep 17 00:00:00 2001 From: "Jon M. Mease" Date: Sat, 17 Dec 2016 10:37:33 -0500 Subject: [PATCH] Trap warning introduced by GH14432 in test_groupby_multi_categorical_as_index --- pandas/tests/groupby/test_categorical.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pandas/tests/groupby/test_categorical.py b/pandas/tests/groupby/test_categorical.py index d3c7bc2adbb4a..99bea3a10115b 100644 --- a/pandas/tests/groupby/test_categorical.py +++ b/pandas/tests/groupby/test_categorical.py @@ -349,9 +349,19 @@ def test_groupby_multi_categorical_as_index(self): 'B': [101.0, nan, nan, 205.0, nan, nan]}, columns=['cat', 'A', 'B']) + group_columns = ['cat', 'A'] + for name in [None, 'X', 'B', 'cat']: df.index = Index(list("abc"), name=name) - result = df.groupby(['cat', 'A'], as_index=False).sum() + + if name in group_columns and name in df.index.names: + with tm.assert_produces_warning(FutureWarning, + check_stacklevel=False): + result = df.groupby(group_columns, as_index=False).sum() + + else: + result = df.groupby(group_columns, as_index=False).sum() + tm.assert_frame_equal(result, expected, check_index_type=True) def test_groupby_preserve_categorical_dtype(self):