Skip to content

Commit dcf4fb4

Browse files
committed
dispatch to Index types on _reduce
Decimal is a numeric type, support in groupby
1 parent 9605083 commit dcf4fb4

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

pandas/core/arrays/base.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,9 @@ def _reduce(self, op, name, axis=0, skipna=True, numeric_only=None,
735735
-------
736736
scalar
737737
"""
738-
raise AbstractMethodError(self)
738+
739+
# we dispatchh to the nanops operations
740+
return op(self, axis=axis, skipna=skipna)
739741

740742

741743
class ExtensionScalarOpsMixin(ExtensionOpsMixin):

pandas/tests/extension/decimal/array.py

+25
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,31 @@ def _na_value(self):
137137
def _concat_same_type(cls, to_concat):
138138
return cls(np.concatenate([x._data for x in to_concat]))
139139

140+
def _reduce(self, op, name, axis=0, skipna=True, numeric_only=None,
141+
filter_type=None, **kwds):
142+
"""Return a scalar result of performing the op
143+
144+
Parameters
145+
----------
146+
op : callable
147+
function to apply to the array
148+
name : str
149+
name of the function
150+
axis : int, default 0
151+
axis over which to apply, defined as 0 currently
152+
skipna : bool, default True
153+
if True, skip NaN values
154+
numeric_only : bool, optional
155+
if True, only perform numeric ops
156+
filter_type : str, optional
157+
kwds : dict
158+
159+
Returns
160+
-------
161+
scalar
162+
"""
163+
return op(self.data, axis=axis, skipna=skipna)
164+
140165

141166
DecimalArray._add_arithmetic_ops()
142167
DecimalArray._add_comparison_ops()

0 commit comments

Comments
 (0)