Skip to content
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

[BUG] Including a NaN (float) value should force Index to cast to float64. #9822

Closed
Tracked by #9815
bdice opened this issue Dec 2, 2021 · 0 comments · Fixed by #9893
Closed
Tracked by #9815

[BUG] Including a NaN (float) value should force Index to cast to float64. #9822

bdice opened this issue Dec 2, 2021 · 0 comments · Fixed by #9893
Assignees
Labels
bug Something isn't working Python Affects Python cuDF API.

Comments

@bdice
Copy link
Contributor

bdice commented Dec 2, 2021

Describe the bug
Constructing an integer index with a NaN value produces an index of ints with a null value, rather than casting to floats.

Steps/Code to reproduce bug
This doctest (#9815) is failing:

>>> idx = cudf.Index([1, 2, 3, 4, np.nan])
>>> idx.is_floating()
True

The index is actually getting this value:

>>> cudf.Index([1, 2, 3, 4, np.nan])
Int64Index([1, 2, 3, 4, <NA>], dtype='int64')

Expected behavior
NaN is a float value, and thus should force the column to cast to floats. This would match the expectation of other float values like 3.5 (instead of NaN). This is what pandas does:

>>> pd.Index([1, 2, 3, 4, np.nan])
Float64Index([1.0, 2.0, 3.0, 4.0, nan], dtype='float64')
@bdice bdice added bug Something isn't working Needs Triage Need team to review and classify labels Dec 2, 2021
@bdice bdice added Python Affects Python cuDF API. and removed Needs Triage Need team to review and classify labels Dec 2, 2021
@bdice bdice mentioned this issue Dec 2, 2021
9 tasks
@galipremsagar galipremsagar self-assigned this Dec 2, 2021
rapids-bot bot pushed a commit that referenced this issue Dec 14, 2021
Fixes: #9822 

This PR introduces `nan_as_null` parameter to `cudf.Index` constructor which is similar to the one present in `cudf.Series` constructor.

Authors:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

Approvers:
  - Ashwin Srinath (https://github.com/shwina)

URL: #9893
rapids-bot bot pushed a commit that referenced this issue Jan 15, 2022
This PR adds doctests and resolves #9513. Several issues were found by running doctests that have now been resolved:

- [x] #9821
- [x] #9822
- [x] #9823
- [x] #9824
- [x] #9825
- [x] #9826
- [x] #9827
- [x] #9828 (workaround by deleting doctests)
- [x] #9829

Authors:
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - Ashwin Srinath (https://github.com/shwina)
  - Vyas Ramasubramani (https://github.com/vyasr)

URL: #9815
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants