From b2f52d6798a044e6a1bb4e58713c010bf4c8b32c Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Thu, 13 Apr 2017 07:22:59 -0400 Subject: [PATCH] TST: use checkstack level as per comments in groupby.agg with dicts depr testing --- pandas/core/groupby.py | 2 +- pandas/tests/groupby/test_aggregate.py | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pandas/core/groupby.py b/pandas/core/groupby.py index 5e55196803c22..5591ce4b0d4aa 100644 --- a/pandas/core/groupby.py +++ b/pandas/core/groupby.py @@ -2843,7 +2843,7 @@ def _aggregate_multiple_funcs(self, arg, _level): ("using a dict on a Series for aggregation\n" "is deprecated and will be removed in a future " "version"), - FutureWarning, stacklevel=4) + FutureWarning, stacklevel=3) columns = list(arg.keys()) arg = list(arg.items()) diff --git a/pandas/tests/groupby/test_aggregate.py b/pandas/tests/groupby/test_aggregate.py index c2d6422c50d02..22d1de99c48be 100644 --- a/pandas/tests/groupby/test_aggregate.py +++ b/pandas/tests/groupby/test_aggregate.py @@ -310,18 +310,15 @@ def test_agg_dict_renaming_deprecation(self): 'B': range(5), 'C': range(5)}) - with tm.assert_produces_warning(FutureWarning, - check_stacklevel=False) as w: + with tm.assert_produces_warning(FutureWarning) as w: df.groupby('A').agg({'B': {'foo': ['sum', 'max']}, 'C': {'bar': ['count', 'min']}}) assert "using a dict with renaming" in str(w[0].message) - with tm.assert_produces_warning(FutureWarning, - check_stacklevel=False): + with tm.assert_produces_warning(FutureWarning): df.groupby('A')[['B', 'C']].agg({'ma': 'max'}) - with tm.assert_produces_warning(FutureWarning, - check_stacklevel=False) as w: + with tm.assert_produces_warning(FutureWarning) as w: df.groupby('A').B.agg({'foo': 'count'}) assert "using a dict on a Series for aggregation" in str( w[0].message)