Skip to content

Commit fcb8b80

Browse files
authored
REF: unused group_keys, indexer from BaseGrouper (#51214)
REF: groupby group_keys, indexer from BaseGrouper
1 parent 6a83d3c commit fcb8b80

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

pandas/core/groupby/ops.py

+13-14
Original file line numberDiff line numberDiff line change
@@ -677,11 +677,6 @@ class BaseGrouper:
677677
for example for grouper list to groupby, need to pass the list
678678
sort : bool, default True
679679
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
685680
686681
"""
687682

@@ -692,17 +687,13 @@ def __init__(
692687
axis: Index,
693688
groupings: Sequence[grouper.Grouping],
694689
sort: bool = True,
695-
group_keys: bool = True,
696-
indexer: npt.NDArray[np.intp] | None = None,
697690
dropna: bool = True,
698691
) -> None:
699692
assert isinstance(axis, Index), axis
700693

701694
self.axis = axis
702695
self._groupings: list[grouper.Grouping] = list(groupings)
703696
self._sort = sort
704-
self.group_keys = group_keys
705-
self.indexer = indexer
706697
self.dropna = dropna
707698

708699
@property
@@ -886,14 +877,10 @@ def group_info(self) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp], int]:
886877

887878
return comp_ids, obs_group_ids, ngroups
888879

889-
@final
890880
@cache_readonly
891881
def codes_info(self) -> npt.NDArray[np.intp]:
892882
# return the codes of items in original grouped axis
893883
ids, _, _ = self.group_info
894-
if self.indexer is not None:
895-
sorter = np.lexsort((ids, self.indexer))
896-
ids = ids[sorter]
897884
return ids
898885

899886
@final
@@ -1046,7 +1033,10 @@ class BinGrouper(BaseGrouper):
10461033
----------
10471034
bins : the split index of binlabels to group the item of axis
10481035
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
10501040
10511041
Examples
10521042
--------
@@ -1100,6 +1090,15 @@ def nkeys(self) -> int:
11001090
# still matches len(self.groupings), but we can hard-code
11011091
return 1
11021092

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+
11031102
def get_iterator(self, data: NDFrame, axis: AxisInt = 0):
11041103
"""
11051104
Groupby iterator

0 commit comments

Comments
 (0)