We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9852678 commit 7777766Copy full SHA for 7777766
pandas/core/groupby/grouper.py
@@ -350,9 +350,13 @@ def _set_grouper(
350
unsorted_ax = self._grouper.take(reverse_indexer)
351
ax = unsorted_ax.take(obj.index)
352
elif isinstance(obj.index, RangeIndex):
353
+ # Standard case for RangeIndex
354
ax = self._grouper.take(obj.index)
355
else:
356
# 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.
360
ax = self._grouper
361
362
if key not in obj._info_axis:
0 commit comments