Skip to content

Commit 00eb06c

Browse files
committed
ENH: add masked mean function
1 parent d481c13 commit 00eb06c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pandas/core/array_algos/masked_reductions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,7 @@ def min(values: np.ndarray, mask: np.ndarray, *, skipna: bool = True):
107107

108108
def max(values: np.ndarray, mask: np.ndarray, *, skipna: bool = True):
109109
return _minmax(np.max, values=values, mask=mask, skipna=skipna)
110+
111+
112+
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)

0 commit comments

Comments
 (0)