Skip to content

Commit 0ca49fc

Browse files
authored
API: make FloatingArray.astype consistent with IntegerArray/BooleanArray (#50028)
1 parent 2411042 commit 0ca49fc

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

pandas/core/arrays/masked.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
from pandas.util._decorators import doc
3939
from pandas.util._validators import validate_fillna_kwargs
4040

41-
from pandas.core.dtypes.astype import astype_nansafe
4241
from pandas.core.dtypes.base import ExtensionDtype
4342
from pandas.core.dtypes.common import (
4443
is_bool,
@@ -492,10 +491,6 @@ def astype(self, dtype: AstypeArg, copy: bool = True) -> ArrayLike:
492491
raise ValueError("cannot convert float NaN to bool")
493492

494493
data = self.to_numpy(dtype=dtype, na_value=na_value, copy=copy)
495-
if self.dtype.kind == "f":
496-
# TODO: make this consistent between IntegerArray/FloatingArray,
497-
# see test_astype_str
498-
return astype_nansafe(data, dtype, copy=False)
499494
return data
500495

501496
__array_priority__ = 1000 # higher than ndarray so ops dispatch to us

pandas/tests/arrays/floating/test_astype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def test_astype_to_integer_array():
6565

6666
def test_astype_str():
6767
a = pd.array([0.1, 0.2, None], dtype="Float64")
68-
expected = np.array(["0.1", "0.2", "<NA>"], dtype=object)
68+
expected = np.array(["0.1", "0.2", "<NA>"], dtype="U32")
6969

7070
tm.assert_numpy_array_equal(a.astype(str), expected)
7171
tm.assert_numpy_array_equal(a.astype("str"), expected)

0 commit comments

Comments
 (0)