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
install_uliengineering.sh
pip install -U UliEngineering
and then use datetime64_unit()
from UliEngineering.Utils.NumPy
like this:
datetime64_resolution_example.py
from UliEngineering.Utils.NumPy import *
my_datetime = datetime64_now()
print(datetime64_resolution(my_datetime)) # Prints "us"
Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow