Skip to content

Commit bcf8f05

Browse files
committed
ENH: add masked mean function
1 parent 4628665 commit bcf8f05

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pandas/core/array_algos/masked_reductions.py

+4
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,7 @@ def min(values: np.ndarray, mask: np.ndarray, skipna: bool = True):
100100

101101
def max(values: np.ndarray, mask: np.ndarray, skipna: bool = True):
102102
return _minmax(np.max, values=values, mask=mask, skipna=skipna)
103+
104+
105+
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)

0 commit comments

Comments
 (0)