From 63fa1285aaeb835bd3afdcb65b7d47eb941e8ec1 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/test_groupby.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pandas/tests/test_groupby.py b/pandas/tests/test_groupby.py index 7b98a453957528..65e98b17a228e6 100644 --- a/pandas/tests/test_groupby.py +++ b/pandas/tests/test_groupby.py @@ -6778,9 +6778,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):