BUG: Inconsistent NaN casting to float64
#46985
Labels
API Design
Bug
Duplicate Report
Duplicate issue or pull request
Missing-data
np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
NA - MaskedArrays
Related to pd.NA and nullable extension arrays
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
Pandas inconsistently casts
pd.NA
values toNaN
when casting fromInt64
vsobject
. The latter causes anTypeError
, but the former successfully convertspd.NA
values toNaN
.Expected Behavior
Either these both fail, or they both succeed
Installed Versions
INSTALLED VERSIONS
commit : 04e01a1
python : 3.8.12.final.0
python-bits : 64
OS : Darwin
OS-release : 21.0.1
Version : Darwin Kernel Version 21.0.1: Tue Sep 14 20:56:24 PDT 2021; root:xnu-8019.30.61~4/RELEASE_ARM64_T6000
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.UTF-8
pandas : 1.5.0.dev0+769.g04e01a1de0
numpy : 1.22.3
pytz : 2022.1
dateutil : 2.8.2
pip : 21.1.1
setuptools : 56.0.0
Cython : 0.29.28
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 8.3.0
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
markupsafe : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
The text was updated successfully, but these errors were encountered: