You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Casting a NaT with a timedelta64or datetime64 to float64 return big negative number #8449
I'm using numpy 1.11.2 on Linux and here is what I get:
In [1]: import numpy
In [2]: x = numpy.array([3, None], 'm8[D]')
In [3]: x.astype('float64')
array([ 3.00000000e+00, -9.22337204e+18])
This behavior seems to be the same for datetime64 as well.
IMHO, this causes a potentially dangerous problem where the wrong calculation is returned silently and the negative most int64 is used instead of nan. For example, if you want to do a calculation in dates and then convert this to float to calculate the number of years (approximately), you can't just do an arr.astype('float64') / 365 since the NaT to nan is not handled correctly.
Activity
mattip commentedon Sep 4, 2018
The inverse of issue #8780