Skip to content

Commit 7777766

Browse files
author
aram-cedarwood
committed
add comments
1 parent 9852678 commit 7777766

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pandas/core/groupby/grouper.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,13 @@ def _set_grouper(
350350
unsorted_ax = self._grouper.take(reverse_indexer)
351351
ax = unsorted_ax.take(obj.index)
352352
elif isinstance(obj.index, RangeIndex):
353+
# Standard case for RangeIndex
353354
ax = self._grouper.take(obj.index)
354355
else:
355356
# GH 59350
357+
# If index is not RangeIndex and not sorted here,
358+
# avoid re-taking based on potentially mis-ordered obj.index.
359+
# self._grouper should already align with obj's values via key.
356360
ax = self._grouper
357361
else:
358362
if key not in obj._info_axis:

0 commit comments

Comments
 (0)