How to get unit/resolution of NumPy np.timedelta64 object
In order to get the unit (e.g. us, ms, ns, …) of a np.timedelta64 object like
timedelta_unit_resolution.py
my_timedelta = np.timedelta64(625, 'us') # Unit is 'us'first install my Python 3 UliEngineering library using
example.sh
pip install -U UliEngineeringand then use timedelta64_unit() from UliEngineering.Utils.NumPy like this:
example.py
import numpy as np
from UliEngineering.Utils.NumPy import *
my_timedelta = np.timedelta64(625, 'us')
print(timedelta64_resolution(my_timedelta)) # 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