Skip to content
Open
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
10 changes: 9 additions & 1 deletion pandas/core/reshape/reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,15 @@ def _make_selectors(self) -> None:
self.group_index = comp_index
self.mask = mask
if self.sort:
self.compressor = comp_index.searchsorted(np.arange(ngroups))
from pandas.compat import PY314
from pandas.compat.numpy import np_version_gt2

# GH 63314: avoid searchsorted bug with py3.14 + numpy < 2.0
if PY314 and not np_version_gt2:
# use manual approach instead of buggy searchsorted
self.compressor = np.sort(np.unique(comp_index, return_index=True)[1])
else:
self.compressor = comp_index.searchsorted(np.arange(ngroups))
else:
self.compressor = np.sort(np.unique(comp_index, return_index=True)[1])

Expand Down
Loading