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
my_timedelta = np.timedelta64(625, 'us') # Unit is 'us'
first install my Python 3 UliEngineering library using
sudo pip3 install -U UliEngineering
and then use timedelta64_unit()
from UliEngineering.Utils.NumPy
like this:
import numpy as np
from UliEngineering.Utils.NumPy import *
my_timedelta = np.timedelta64(625, 'us')
print(timedelta64_resolution(my_timedelta)) # Prints "us"