Skip to content

Commit 11b1318

Browse files
committed
modified
1 parent 8894d0e commit 11b1318

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pandas/core/array_algos/masked_reductions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ 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):
113-
113+
114114
_sum = _sumprod(np.sum, values=values, mask=mask, skipna=skipna)
115115
count = np.count_nonzero(~mask)
116116
mean_value = _sum / count

pandas/tests/reductions/test_reductions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,12 @@ def test_ops_consistency_on_empty(self, method):
689689
result = getattr(Series(dtype=float), method)()
690690
assert pd.isna(result)
691691

692+
# Empty Mean
693+
if method == "mean":
694+
s = Series([], dtype=float)
695+
result = getattr(s, method)()
696+
assert np.isnan(result)
697+
692698
# timedelta64[ns]
693699
tdser = Series([], dtype="m8[ns]")
694700
if method == "var":

0 commit comments

Comments
 (0)