Is there a reason why conversion from datetime.datetime
array, without specifying units us
, converts the datetime to full day? Or is this a bug?
import numpy as np
import datetime
print(np.array([datetime.datetime(2018, 5, 15, 6, 0),datetime.datetime(2018, 5, 15, 6, 30)]).astype('datetime64[us]'))
print(np.array([datetime.datetime(2018, 5, 15, 6, 0),datetime.datetime(2018, 5, 15, 6, 30)]).astype('datetime64'))
output
['2018-05-15T06:00:00.000000' '2018-05-15T06:30:00.000000']
['2018-05-15' '2018-05-15']
numpy version 1.14.3 and python 3.6.3
From the numpy documentation, I cannot see that default unit of datetime64 is day. from https://docs.scipy.org/doc/numpy-1.14.0/reference/arrays.datetime.html
>>> np.array(['2001-01-01T12:00', '2002-02-03T13:56:03.172'], dtype='datetime64')
array(['2001-01-01T12:00:00.000-0600', '2002-02-03T13:56:03.172-0600'], dtype='datetime64[ms]')