Skip to content

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

Closed
@jbrockmendel

Description

@jbrockmendel
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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions