Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
9 changes: 3 additions & 6 deletions pandas/tests/groupby/test_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down