How to get unit/resolution of NumPy np.datetime64 object
NumPy’s datetime64
objects are represented as 64 bit integers (that’s what the 64
in the name means).
In order to find out what the resolution (e.g. us
, ns
etc) first install my Python 3 UliEngineering library using
sudo pip3 install -U UliEngineering
and then use datetime64_unit()
from UliEngineering.Utils.NumPy
like this:
from UliEngineering.Utils.NumPy import *
my_datetime = datetime64_now()
print(datetime64_resolution(my_datetime)) # Prints "us"