Skip to content

Commit d9b3993

Browse files
jbrockmendelWillAyd
authored andcommitted
reduction-> libreduction for grepability (#28184)
1 parent 03b3c8f commit d9b3993

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

pandas/core/apply.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import numpy as np
55

6-
from pandas._libs import reduction
6+
from pandas._libs import reduction as libreduction
77
from pandas.util._decorators import cache_readonly
88

99
from pandas.core.dtypes.common import (
@@ -221,7 +221,7 @@ def apply_raw(self):
221221
""" apply to the values as a numpy array """
222222

223223
try:
224-
result = reduction.compute_reduction(self.values, self.f, axis=self.axis)
224+
result = libreduction.compute_reduction(self.values, self.f, axis=self.axis)
225225
except Exception:
226226
result = np.apply_along_axis(self.f, self.axis, self.values)
227227

@@ -281,7 +281,7 @@ def apply_standard(self):
281281
dummy = Series(empty_arr, index=index, dtype=values.dtype)
282282

283283
try:
284-
result = reduction.compute_reduction(
284+
result = libreduction.compute_reduction(
285285
values, self.f, axis=self.axis, dummy=dummy, labels=labels
286286
)
287287
return self.obj._constructor_sliced(result, index=labels)

pandas/core/groupby/ops.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from pandas._libs import NaT, iNaT, lib
1414
import pandas._libs.groupby as libgroupby
15-
import pandas._libs.reduction as reduction
15+
import pandas._libs.reduction as libreduction
1616
from pandas.errors import AbstractMethodError
1717
from pandas.util._decorators import cache_readonly
1818

@@ -207,7 +207,7 @@ def apply(self, f, data, axis=0):
207207
if len(result_values) == len(group_keys):
208208
return group_keys, result_values, mutated
209209

210-
except reduction.InvalidApply:
210+
except libreduction.InvalidApply:
211211
# Cannot fast apply on MultiIndex (_has_complex_internals).
212212
# This Exception is also raised if `f` triggers an exception
213213
# but it is preferable to raise the exception in Python.
@@ -678,7 +678,7 @@ def _aggregate_series_fast(self, obj, func):
678678
indexer = get_group_index_sorter(group_index, ngroups)
679679
obj = obj.take(indexer)
680680
group_index = algorithms.take_nd(group_index, indexer, allow_fill=False)
681-
grouper = reduction.SeriesGrouper(obj, func, group_index, ngroups, dummy)
681+
grouper = libreduction.SeriesGrouper(obj, func, group_index, ngroups, dummy)
682682
result, counts = grouper.get_result()
683683
return result, counts
684684

@@ -851,7 +851,7 @@ def groupings(self):
851851

852852
def agg_series(self, obj, func):
853853
dummy = obj[:0]
854-
grouper = reduction.SeriesBinGrouper(obj, func, self.bins, dummy)
854+
grouper = libreduction.SeriesBinGrouper(obj, func, self.bins, dummy)
855855
return grouper.get_result()
856856

857857

@@ -939,7 +939,7 @@ def fast_apply(self, f, names):
939939
return [], True
940940

941941
sdata = self._get_sorted_data()
942-
return reduction.apply_frame_axis0(sdata, f, names, starts, ends)
942+
return libreduction.apply_frame_axis0(sdata, f, names, starts, ends)
943943

944944
def _chop(self, sdata, slice_obj):
945945
if self.axis == 0:

pandas/tests/groupby/test_bin_groupby.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from numpy import nan
33
import pytest
44

5-
from pandas._libs import groupby, lib, reduction
5+
from pandas._libs import groupby, lib, reduction as libreduction
66

77
from pandas.core.dtypes.common import ensure_int64
88

@@ -18,7 +18,7 @@ def test_series_grouper():
1818

1919
labels = np.array([-1, -1, -1, 0, 0, 0, 1, 1, 1, 1], dtype=np.int64)
2020

21-
grouper = reduction.SeriesGrouper(obj, np.mean, labels, 2, dummy)
21+
grouper = libreduction.SeriesGrouper(obj, np.mean, labels, 2, dummy)
2222
result, counts = grouper.get_result()
2323

2424
expected = np.array([obj[3:6].mean(), obj[6:].mean()])
@@ -34,7 +34,7 @@ def test_series_bin_grouper():
3434

3535
bins = np.array([3, 6])
3636

37-
grouper = reduction.SeriesBinGrouper(obj, np.mean, bins, dummy)
37+
grouper = libreduction.SeriesBinGrouper(obj, np.mean, bins, dummy)
3838
result, counts = grouper.get_result()
3939

4040
expected = np.array([obj[:3].mean(), obj[3:6].mean(), obj[6:].mean()])
@@ -120,31 +120,31 @@ class TestMoments:
120120
class TestReducer:
121121
def test_int_index(self):
122122
arr = np.random.randn(100, 4)
123-
result = reduction.compute_reduction(arr, np.sum, labels=Index(np.arange(4)))
123+
result = libreduction.compute_reduction(arr, np.sum, labels=Index(np.arange(4)))
124124
expected = arr.sum(0)
125125
assert_almost_equal(result, expected)
126126

127-
result = reduction.compute_reduction(
127+
result = libreduction.compute_reduction(
128128
arr, np.sum, axis=1, labels=Index(np.arange(100))
129129
)
130130
expected = arr.sum(1)
131131
assert_almost_equal(result, expected)
132132

133133
dummy = Series(0.0, index=np.arange(100))
134-
result = reduction.compute_reduction(
134+
result = libreduction.compute_reduction(
135135
arr, np.sum, dummy=dummy, labels=Index(np.arange(4))
136136
)
137137
expected = arr.sum(0)
138138
assert_almost_equal(result, expected)
139139

140140
dummy = Series(0.0, index=np.arange(4))
141-
result = reduction.compute_reduction(
141+
result = libreduction.compute_reduction(
142142
arr, np.sum, axis=1, dummy=dummy, labels=Index(np.arange(100))
143143
)
144144
expected = arr.sum(1)
145145
assert_almost_equal(result, expected)
146146

147-
result = reduction.compute_reduction(
147+
result = libreduction.compute_reduction(
148148
arr, np.sum, axis=1, dummy=dummy, labels=Index(np.arange(100))
149149
)
150150
assert_almost_equal(result, expected)

0 commit comments

Comments
 (0)