We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 442e071 commit fd9a124Copy full SHA for fd9a124
pandas/core/groupby/ops.py
@@ -39,6 +39,7 @@
39
from pandas.core.dtypes.missing import _maybe_fill, isna
40
41
import pandas.core.algorithms as algorithms
42
+from pandas.core.arrays import Categorical
43
from pandas.core.base import SelectionMixin
44
import pandas.core.common as com
45
from pandas.core.frame import DataFrame
@@ -758,7 +759,11 @@ def _get_grouper(self):
758
759
We have a specific method of grouping, so cannot
760
convert to a Index for our grouper.
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
767
768
def get_iterator(self, data: FrameOrSeries, axis: int = 0):
769
0 commit comments