8000 COMPAT: Emit warning when groupby by a tuple by TomAugspurger · Pull Request #18731 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

COMPAT: Emit warning when groupby by a tuple #18731

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 12 commits into from
Dec 18, 2017
Prev Previous commit
Next Next commit
xfail
  • Loading branch information
TomAugspurger committed Dec 15, 2017
commit 38ef818bc446049fb748cdef64dde222bfd70078
7 changes: 4 additions & 3 deletions pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2755,13 +2755,14 @@ def test_tuple_warns_unhashable(self):

assert "Interpreting tuple 'by' as a list" in str(w[0].message)

@pytest.mark.xfail(reason="GH-18798")
def test_tuple_correct_keyerror(self):
# https://github.com/pandas-dev/pandas/issues/18798
df = pd.DataFrame(1, index=range(3),
columns=pd.MultiIndex.from_product([[1, 2],
[3, 4]]))
with tm.assert_produces_warning(FutureWarning): # just silence
with tm.assert_raises_regex(KeyError, "(7, 8)"):
df.groupby((7, 8)).mean()
with tm.assert_raises_regex(KeyError, "(7, 8)"):
df.groupby((7, 8)).mean()


def _check_groupby(df, result, keys, field, f=lambda x: x.sum()):
Expand Down
0