From 6ee8fcbbf82e7fd5e42fb8207d591a9817b977a2 Mon Sep 17 00:00:00 2001 From: Richard Shadrach Date: Tue, 14 Nov 2023 17:00:51 -0500 Subject: [PATCH] fixup for int32 --- pandas/core/groupby/ops.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/core/groupby/ops.py b/pandas/core/groupby/ops.py index 64f5df7489b633..85f694be62b599 100644 --- a/pandas/core/groupby/ops.py +++ b/pandas/core/groupby/ops.py @@ -786,6 +786,7 @@ def result_index_and_ids(self) -> tuple[Index, np.ndarray]: shape = tuple(len(level) for level in ob_levels) group_index = get_group_index(ob_codes, shape, sort=True, xnull=True) ob_ids, obs_group_ids = compress_group_index(group_index, sort=self._sort) + ob_ids = ensure_platform_int(ob_ids) ob_index_codes = decons_obs_group_ids( ob_ids, obs_group_ids, shape, ob_codes, xnull=True ) @@ -833,9 +834,9 @@ def result_index_and_ids(self) -> tuple[Index, np.ndarray]: if self._sort: sorter = result_index.argsort() result_index = result_index.take(sorter) - _, inverse = np.unique(sorter, return_index=True) + _, index = np.unique(sorter, return_index=True) ids = ensure_platform_int(ids) - ids = inverse.take(ids) + ids = index.take(ids) else: ids, uniques = compress_group_index(ids, sort=False) ids = ensure_platform_int(ids)