Converting Numpy Datetime64 To Long Integer And Back
How to convert NumPy datetime64 to a long ineteger and back? import numpy as np import datetime np.datetime64(datetime.datetime.now()).astype(long) Gives a value of 1511975032478
Solution 1:
You need to specify the units of the long int (in this case, microseconds).
np.datetime64(np.datetime64(datetime.datetime.now()).astype(long), 'us')
returns
numpy.datetime64('2017-11-29T17:11:44.638713')
Solution 2:
'us' converts to microseconds. If you require a different format use:
as shown here
Post a Comment for "Converting Numpy Datetime64 To Long Integer And Back"