Skip to content

Commit fd9a124

Browse files
committed
BUG: partial fix to pandas-dev#33132
1 parent 442e071 commit fd9a124

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pandas/core/groupby/ops.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from pandas.core.dtypes.missing import _maybe_fill, isna
4040

4141
import pandas.core.algorithms as algorithms
42+
from pandas.core.arrays import Categorical
4243
from pandas.core.base import SelectionMixin
4344
import pandas.core.common as com
4445
from pandas.core.frame import DataFrame
@@ -758,7 +759,11 @@ def _get_grouper(self):
758759
We have a specific method of grouping, so cannot
759760
convert to a Index for our grouper.
760761
"""
761-
return self
762+
# Return an index based on codes_info
763+
grouper = self.result_index._constructor(
764+
Categorical.from_codes(self.codes_info, self.result_index)
765+
)
766+
return grouper
762767

763768
def get_iterator(self, data: FrameOrSeries, axis: int = 0):
764769
"""

0 commit comments

Comments
 (0)