BUG: Raise when casting infinity to int by dsaxton · Pull Request #28475 · pandas-dev/pandas (original) (raw)
Raises a ValueError
when attempting to cast a Float64Index
with infinite values to a (non-ExtensionArray
) integer dtype. Currently this returns a garbage value:
idx
# Float64Index([1.0, 2.0, inf], dtype='float64')
idx.astype(int)
# Int64Index([1, 2, -9223372036854775808], dtype='int64')