Skip to content

Commit d063853

Browse files
committed
ENH: masked mean functioning
1 parent b37f635 commit d063853

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pandas/core/array_algos/masked_reductions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,8 @@ def max(values: np.ndarray, mask: np.ndarray, *, skipna: bool = True):
110110

111111

112112
def mean(values: np.ndarray, mask: np.ndarray, skipna: bool = True, min_count: int = 0):
113-
return sum(values=values, mask=mask, skipna=skipna, min_count=min_count) / np.count_nonzero(~mask)
113+
return _sumprod(
114+
np.sum, values=values, mask=mask, skipna=skipna, min_count=min_count
115+
) / np.count_nonzero(~mask)
116+
114117

pandas/core/arrays/masked.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def _reduce(self, name: str, *, skipna: bool = True, **kwargs):
394394
data = self._data
395395
mask = self._mask
396396

397-
if name in {"sum", "prod", "min", "max"}:
397+
if name in {"sum", "prod", "min", "max", "mean"}:
398398
op = getattr(masked_reductions, name)
399399
return op(data, mask, skipna=skipna, **kwargs)
400400

0 commit comments

Comments
 (0)