Skip to content

Commit a29cd9a

Browse files
committed
add a test
1 parent 2b69e46 commit a29cd9a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pandas/core/groupby/ops.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,6 @@ def _get_splitter(self, data: NDFrame) -> DataSplitter:
640640
@cache_readonly
641641
def indices(self) -> dict[Hashable, npt.NDArray[np.intp]]:
642642
"""dict {group name -> group indices}"""
643-
644643
if len(self.groupings) == 1 and isinstance(self.result_index, CategoricalIndex):
645644
# This shows unused categories in indices GH#38642
646645
return self.groupings[0].indices

pandas/tests/groupby/test_groupby.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,3 +2985,10 @@ def test_groupby_agg_namedagg_with_duplicate_columns():
29852985
)
29862986

29872987
tm.assert_frame_equal(result, expected)
2988+
2989+
2990+
def test_groupby_keys_1length_list():
2991+
# GH#58945
2992+
df = DataFrame({"x": [10, 20, 30], "y": ["a", "b", "c"]})
2993+
result = df.groupby(["x"]).groups
2994+
assert all(isinstance(key, tuple) for key in result.keys())

0 commit comments

Comments
 (0)