Skip to content

Commit

Permalink
dispatch to Index types on _reduce
Browse files Browse the repository at this point in the history
Decimal is a numeric type, support in groupby
  • Loading branch information
jreback committed Sep 19, 2018
1 parent ba96107 commit 6becc87
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,9 @@ def _reduce(self, op, name, axis=0, skipna=True, numeric_only=None,
-------
scalar
"""
raise AbstractMethodError(self)

# we dispatchh to the nanops operations
return op(self, axis=axis, skipna=skipna)


class ExtensionScalarOpsMixin(ExtensionOpsMixin):
Expand Down
25 changes: 25 additions & 0 deletions pandas/tests/extension/decimal/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,31 @@ def _na_value(self):
def _concat_same_type(cls, to_concat):
return cls(np.concatenate([x._data for x in to_concat]))

def _reduce(self, op, name, axis=0, skipna=True, numeric_only=None,
filter_type=None, **kwds):
"""Return a scalar result of performing the op
Parameters
----------
op : callable
function to apply to the array
name : str
name of the function
axis : int, default 0
axis over which to apply, defined as 0 currently
skipna : bool, default True
if True, skip NaN values
numeric_only : bool, optional
if True, only perform numeric ops
filter_type : str, optional
kwds : dict
Returns
-------
scalar
"""
return op(self.data, axis=axis, skipna=skipna)


DecimalArray._add_arithmetic_ops()
DecimalArray._add_comparison_ops()

0 comments on commit 6becc87

Please sign in to comment.