BUG: astype_nansafe from float to unsigned int with negatives (original) (raw)

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?