Skip to content

Commit c479d93

Browse files
authored
REF: more distinctive names for BaseGrouper.aggregate, transform (#38161)
1 parent 6301438 commit c479d93

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

pandas/core/groupby/generic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,8 +1061,8 @@ def cast_agg_result(result, values: ArrayLike, how: str) -> ArrayLike:
10611061
def blk_func(bvalues: ArrayLike) -> ArrayLike:
10621062

10631063
try:
1064-
result, _ = self.grouper.aggregate(
1065-
bvalues, how, axis=1, min_count=min_count
1064+
result, _ = self.grouper._cython_operation(
1065+
"aggregate", bvalues, how, axis=1, min_count=min_count
10661066
)
10671067
except NotImplementedError:
10681068
# generally if we have numeric_only=False

pandas/core/groupby/groupby.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -982,16 +982,21 @@ def _transform_should_cast(self, func_nm: str) -> bool:
982982
assert filled_series is not None
983983
return filled_series.gt(0).any() and func_nm not in base.cython_cast_blocklist
984984

985-
def _cython_transform(self, how: str, numeric_only: bool = True, **kwargs):
985+
def _cython_transform(
986+
self, how: str, numeric_only: bool = True, axis: int = 0, **kwargs
987+
):
986988
output: Dict[base.OutputKey, np.ndarray] = {}
989+
987990
for idx, obj in enumerate(self._iterate_slices()):
988991
name = obj.name
989992
is_numeric = is_numeric_dtype(obj.dtype)
990993
if numeric_only and not is_numeric:
991994
continue
992995

993996
try:
994-
result, _ = self.grouper.transform(obj.values, how, **kwargs)
997+
result, _ = self.grouper._cython_operation(
998+
"transform", obj.values, how, axis, **kwargs
999+
)
9951000
except NotImplementedError:
9961001
continue
9971002

@@ -1067,8 +1072,8 @@ def _cython_agg_general(
10671072
if numeric_only and not is_numeric:
10681073
continue
10691074

1070-
result, agg_names = self.grouper.aggregate(
1071-
obj._values, how, min_count=min_count
1075+
result, agg_names = self.grouper._cython_operation(
1076+
"aggregate", obj._values, how, axis=0, min_count=min_count
10721077
)
10731078

10741079
if agg_names:

pandas/core/groupby/ops.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -588,16 +588,6 @@ def _cython_operation(
588588

589589
return result, names
590590

591-
def aggregate(
592-
self, values, how: str, axis: int = 0, min_count: int = -1
593-
) -> Tuple[np.ndarray, Optional[List[str]]]:
594-
return self._cython_operation(
595-
"aggregate", values, how, axis, min_count=min_count
596-
)
597-
598-
def transform(self, values, how: str, axis: int = 0, **kwargs):
599-
return self._cython_operation("transform", values, how, axis, **kwargs)
600-
601591
def _aggregate(
602592
self, result, counts, values, comp_ids, agg_func, min_count: int = -1
603593
):

0 commit comments

Comments
 (0)