@@ -677,11 +677,6 @@ class BaseGrouper:
677
677
for example for grouper list to groupby, need to pass the list
678
678
sort : bool, default True
679
679
whether this grouper will give sorted result or not
680
- group_keys : bool, default True
681
- indexer : np.ndarray[np.intp], optional
682
- the indexer created by Grouper
683
- some groupers (TimeGrouper) will sort its axis and its
684
- group_info is also sorted, so need the indexer to reorder
685
680
686
681
"""
687
682
@@ -692,17 +687,13 @@ def __init__(
692
687
axis : Index ,
693
688
groupings : Sequence [grouper .Grouping ],
694
689
sort : bool = True ,
695
- group_keys : bool = True ,
696
- indexer : npt .NDArray [np .intp ] | None = None ,
697
690
dropna : bool = True ,
698
691
) -> None :
699
692
assert isinstance (axis , Index ), axis
700
693
701
694
self .axis = axis
702
695
self ._groupings : list [grouper .Grouping ] = list (groupings )
703
696
self ._sort = sort
704
- self .group_keys = group_keys
705
- self .indexer = indexer
706
697
self .dropna = dropna
707
698
708
699
@property
@@ -886,14 +877,10 @@ def group_info(self) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp], int]:
886
877
887
878
return comp_ids , obs_group_ids , ngroups
888
879
889
- @final
890
880
@cache_readonly
891
881
def codes_info (self ) -> npt .NDArray [np .intp ]:
892
882
# return the codes of items in original grouped axis
893
883
ids , _ , _ = self .group_info
894
- if self .indexer is not None :
895
- sorter = np .lexsort ((ids , self .indexer ))
896
- ids = ids [sorter ]
897
884
return ids
898
885
899
886
@final
@@ -1046,7 +1033,10 @@ class BinGrouper(BaseGrouper):
1046
1033
----------
1047
1034
bins : the split index of binlabels to group the item of axis
1048
1035
binlabels : the label list
1049
- indexer : np.ndarray[np.intp]
1036
+ indexer : np.ndarray[np.intp], optional
1037
+ the indexer created by Grouper
1038
+ some groupers (TimeGrouper) will sort its axis and its
1039
+ group_info is also sorted, so need the indexer to reorder
1050
1040
1051
1041
Examples
1052
1042
--------
@@ -1100,6 +1090,15 @@ def nkeys(self) -> int:
1100
1090
# still matches len(self.groupings), but we can hard-code
1101
1091
return 1
1102
1092
1093
+ @cache_readonly
1094
+ def codes_info (self ) -> npt .NDArray [np .intp ]:
1095
+ # return the codes of items in original grouped axis
1096
+ ids , _ , _ = self .group_info
1097
+ if self .indexer is not None :
1098
+ sorter = np .lexsort ((ids , self .indexer ))
1099
+ ids = ids [sorter ]
1100
+ return ids
1101
+
1103
1102
def get_iterator (self , data : NDFrame , axis : AxisInt = 0 ):
1104
1103
"""
1105
1104
Groupby iterator
0 commit comments