Skip to content

Commit eab37ca

Browse files
committed
correct BaseGroupBy.__iter__ and def groups [skip ci]
1 parent b0c4194 commit eab37ca

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pandas/core/groupby/groupby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ def __iter__(self) -> Iterator[tuple[Hashable, NDFrameT]]:
10121012
# mypy: Argument 1 to "len" has incompatible type "Hashable"; expected "Sized"
10131013
if (
10141014
(is_list_like(level) and len(level) == 1) # type: ignore[arg-type]
1015-
or (isinstance(keys, list) and len(keys) == 1)
1015+
or (isinstance(keys, list))
10161016
):
10171017
# GH#42795 - when keys is a list, return tuples even when length is 1
10181018
result = (((key,), group) for key, group in result)

pandas/core/groupby/ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ def size(self) -> Series:
703703
@cache_readonly
704704
def groups(self) -> dict[Hashable, Index]:
705705
"""dict {group name -> group labels}"""
706-
if len(self.groupings) == 1:
706+
if len(self.groupings) == 1 and not isinstance(self.shape, tuple):
707707
return self.groupings[0].groups
708708
result_index, ids = self.result_index_and_ids
709709
values = result_index._values

0 commit comments

Comments
 (0)