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: astype_nansafe from float to unsigned int with negatives #45151

Closed
jbrockmendel opened this issue Jan 1, 2022 · 0 comments · Fixed by #45309
Closed

BUG: astype_nansafe from float to unsigned int with negatives #45151

jbrockmendel opened this issue Jan 1, 2022 · 0 comments · Fixed by #45309
Labels
Astype Bug Dtype Conversions Unexpected or buggy dtype conversions
Milestone

Comments

@jbrockmendel
Copy link
Member

jbrockmendel commented Jan 1, 2022

from pandas.core.dtypes.cast import astype_nansafe
import numpy as np

arr = np.arange(-3, 3).astype(np.float64)

>>> astype_nansafe(arr, np.dtype(np.uint64))
array([18446744073709551613, 18446744073709551614, 18446744073709551615,
                          0,                    1,                    2],
      dtype=uint64)

Looks like we don't do anything special here, just call ndarray.astype. I guess we should raise rather than give nonsense results?

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 1, 2022
@mroeschke mroeschke added Dtype Conversions Unexpected or buggy dtype conversions and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 13, 2022
@jreback jreback added this to the 1.5 milestone Jan 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Astype Bug Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants