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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.22.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ Groupby/Resample/Rolling
^^^^^^^^^^^^^^^^^^^^^^^^

- Bug when grouping by a single column and aggregating with a class like ``list`` or ``tuple`` (:issue:`18079`)
- Fixed regression in :func:`DataFrame.groupby` which would not emit an error when called with a tuple key not in the index (:issue:`18798`)
-
-

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2977,7 +2977,7 @@ def is_in_obj(gpr):


def _is_label_like(val):
return (isinstance(val, compat.string_types) or
return (isinstance(val, (compat.string_types, tuple)) or
(val is not None and is_scalar(val)))


Expand Down
1 change: 0 additions & 1 deletion pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2750,7 +2750,6 @@ 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),
Expand Down