Skip to content

Commit cc63891

Browse files
committed
Apply mask for only the type that can become null after calculation
1 parent 218e5cd commit cc63891

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Diff for: pandas/core/array_algos/masked_reductions.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def _reductions(
5858
else:
5959
return func(values, axis=axis, **kwargs)
6060
else:
61-
mask |= isna(values)
61+
if values.dtype == np.float64:
62+
mask |= isna(values)
6263

6364
if check_below_min_count(values.shape, mask, min_count) and (
6465
axis is None or values.ndim == 1

Diff for: pandas/tests/series/test_reductions.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
from pandas.compat import HAS_PYARROW
77

88
import pandas as pd
9-
from pandas import Series
9+
from pandas import (
10+
Series,
11+
notna,
12+
)
1013
import pandas._testing as tm
1114

1215

@@ -230,4 +233,4 @@ def test_mean_with_skipna():
230233
series1 = Series({"a": 0.0, "b": 1, "c": 1})
231234
series2 = Series({"a": 0.0, "b": 2, "c": 2})
232235
result = series1.convert_dtypes() / series2.convert_dtypes()
233-
assert pd.notna(result.mean(skipna=True))
236+
assert notna(result.mean(skipna=True))

0 commit comments

Comments
 (0)