Skip to content

TST: use checkstack level as per comments in groupby.agg with dicts depr testing #15992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2017
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