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
nanosecond precsion datetime converts to int in stead of datetime #18363
Still reproduces on 2.5.3. The workaround from this thread, t.astype('datetime64[us]').item(), remains the way to go in the meantime.
Closing as a duplicate of #7619, which tracks the same underlying problem and has the discussion on what the right fix is.
Activity
feefladder commentedon Feb 8, 2021
In the specifications of datetime:
it says that conversion to datetime should lose precision or overflow as needed. Not convert to int
Also note that explicit conversion. i.e.
t.astype('datetime[us]').astype(datetime.datetime)works as expected.
gerritholl commentedon Nov 11, 2021
Duplicate of #7619
drf5n commentedon Oct 20, 2023
Maybe this instead:
or
Either way it's casting the ns precision into a datetime-compatible us precision.
InessaPawson commentedon Oct 17, 2026
Still reproduces on 2.5.3. The workaround from this thread,
t.astype('datetime64[us]').item(), remains the way to go in the meantime.Closing as a duplicate of #7619, which tracks the same underlying problem and has the discussion on what the right fix is.