Closed
Description
Currently, in the IntegerArray or BooleanArray astype
, we first convert to object dtype, and then convert to the requested dtype.
For example, in IntegerArray.astype
:
pandas/pandas/core/arrays/integer.py
Lines 551 to 553 in 7d7f885
where self._coerce_to_ndarray()
creates an object ndarray.
In case of converting to integer (and if there are no NaNs), or in case of converting to float, this roundtrip through object dtype is not needed (we can directly convert the _data
and in case of float set NaNs)