Skip to content

Commit f2ed595

Browse files
authored
TST: use checkstack level as per comments in groupby.agg with dicts depr testing (#15992)
1 parent 7322239 commit f2ed595

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

pandas/core/groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2843,7 +2843,7 @@ def _aggregate_multiple_funcs(self, arg, _level):
28432843
("using a dict on a Series for aggregation\n"
28442844
"is deprecated and will be removed in a future "
28452845
"version"),
2846-
FutureWarning, stacklevel=4)
2846+
FutureWarning, stacklevel=3)
28472847

28482848
columns = list(arg.keys())
28492849
arg = list(arg.items())

pandas/tests/groupby/test_aggregate.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -310,18 +310,15 @@ def test_agg_dict_renaming_deprecation(self):
310310
'B': range(5),
311311
'C': range(5)})
312312

313-
with tm.assert_produces_warning(FutureWarning,
314-
check_stacklevel=False) as w:
313+
with tm.assert_produces_warning(FutureWarning) as w:
315314
df.groupby('A').agg({'B': {'foo': ['sum', 'max']},
316315
'C': {'bar': ['count', 'min']}})
317316
assert "using a dict with renaming" in str(w[0].message)
318317

319-
with tm.assert_produces_warning(FutureWarning,
320-
check_stacklevel=False):
318+
with tm.assert_produces_warning(FutureWarning):
321319
df.groupby('A')[['B', 'C']].agg({'ma': 'max'})
322320

323-
with tm.assert_produces_warning(FutureWarning,
324-
check_stacklevel=False) as w:
321+
with tm.assert_produces_warning(FutureWarning) as w:
325322
df.groupby('A').B.agg({'foo': 'count'})
326323
assert "using a dict on a Series for aggregation" in str(
327324
w[0].message)

0 commit comments

Comments
 (0)