Skip to content

BUG: Cannot use pd.NA in a series with float dtype #36587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 3 tasks
thehomebrewnerd opened this issue Sep 23, 2020 · 3 comments
Closed
2 of 3 tasks

BUG: Cannot use pd.NA in a series with float dtype #36587

thehomebrewnerd opened this issue Sep 23, 2020 · 3 comments
Labels
NA - MaskedArrays Related to pd.NA and nullable extension arrays

Comments

@thehomebrewnerd
Copy link

thehomebrewnerd commented Sep 23, 2020

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

import pandas as pd
pd.Series([1.1, pd.NA], dtype='float64')

Problem description

Similar to the issue documented in #36586, if the goal of pd.NA is to provide a missing indicator that can be used across datatypes, it should also work with a float datatype. Currently, if a user attempts to use a pd.NA value in a series with dtype of float, an error is raised: TypeError: float() argument must be a string or a number, not 'NAType'.

This also appears related to the issue mentioned in #36585

Expected Output

import pandas as pd
pd.Series([1.1, pd.NA], dtype='float64')

0    1.1
1    <NA>
dtype: float64

Output of pd.show_versions()

INSTALLED VERSIONS

commit : f2ca0a2
python : 3.7.4.final.0
python-bits : 64
OS : Darwin
OS-release : 18.7.0
Version : Darwin Kernel Version 18.7.0: Mon Feb 10 21:08:45 PST 2020; root:xnu-4903.278.28~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.1.1
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.2
setuptools : 40.8.0
Cython : None
pytest : 6.0.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None

@thehomebrewnerd thehomebrewnerd added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 23, 2020
@dsaxton
Copy link
Member

dsaxton commented Sep 23, 2020

Nullable float dtypes don't exist yet but are being worked on, see #34307.

@dsaxton dsaxton added NA - MaskedArrays Related to pd.NA and nullable extension arrays and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 23, 2020
@TomAugspurger
Copy link
Contributor

Closing this since it's a duplicate of #32265 (comment).

FYI @thehomebrewnerd, your "expected output" section isn't possible. pd.NA is not a float, so it can't be stored in a NumPy float64 array. That should raise.

@thehomebrewnerd
Copy link
Author

thehomebrewnerd commented Sep 24, 2020

@TomAugspurger I guess I didn't search deep enough to see this was being worked in other issues. In any case, I understand your point. As long as there is a float dtype of some sort that can handle pd.NA, analogous to Int64, that seems fine to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NA - MaskedArrays Related to pd.NA and nullable extension arrays
Projects
None yet
Development

No branches or pull requests

3 participants