Skip to content

Commit edc977e

Browse files
committed
Use is_float_dtype
1 parent cc63891 commit edc977e

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
from pandas._libs import missing as libmissing
1414

15+
from pandas.core.dtypes.common import is_float_dtype
16+
1517
from pandas.core.missing import isna
1618
from pandas.core.nanops import check_below_min_count
1719

@@ -58,7 +60,7 @@ def _reductions(
5860
else:
5961
return func(values, axis=axis, **kwargs)
6062
else:
61-
if values.dtype == np.float64:
63+
if is_float_dtype(values):
6264
mask |= isna(values)
6365

6466
if check_below_min_count(values.shape, mask, min_count) and (

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

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

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

1512

@@ -230,7 +227,7 @@ def test_median_with_convertible_string_raises():
230227

231228
def test_mean_with_skipna():
232229
# GH#59965 skipna=True operations don't skip NaN in FloatingArrays
233-
series1 = Series({"a": 0.0, "b": 1, "c": 1})
234-
series2 = Series({"a": 0.0, "b": 2, "c": 2})
235-
result = series1.convert_dtypes() / series2.convert_dtypes()
236-
assert notna(result.mean(skipna=True))
230+
series1 = Series({"a": 0.0, "b": 1, "c": 1}, dtype="Float64")
231+
series2 = Series({"a": 0.0, "b": 2, "c": 2}, dtype="Float64")
232+
result = series1 / series2
233+
assert pd.notna(result.mean(skipna=True))

0 commit comments

Comments
 (0)