Skip to content

Commit 8d49fc8

Browse files
committed
ENH: masked mean functioning
1 parent 34555fb commit 8d49fc8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pandas/core/array_algos/masked_reductions.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,8 @@ def max(values: np.ndarray, mask: np.ndarray, skipna: bool = True):
103103

104104

105105
def mean(values: np.ndarray, mask: np.ndarray, skipna: bool = True, min_count: int = 0):
106-
return sum(values=values, mask=mask, skipna=skipna, min_count=min_count) / np.count_nonzero(~mask)
106+
return _sumprod(
107+
np.sum, values=values, mask=mask, skipna=skipna, min_count=min_count
108+
) / np.count_nonzero(~mask)
109+
107110

pandas/core/arrays/masked.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def _reduce(self, name: str, skipna: bool = True, **kwargs):
334334
data = self._data
335335
mask = self._mask
336336

337-
if name in {"sum", "prod", "min", "max"}:
337+
if name in {"sum", "prod", "min", "max", "mean"}:
338338
op = getattr(masked_reductions, name)
339339
return op(data, mask, skipna=skipna, **kwargs)
340340

0 commit comments

Comments
 (0)