Numpy: Extract days from timedelta64
To extract the integer value of days from a numpy.timedelta64
, you divide it with a
timedelta64
of one day:
>>> x = np.timedelta64(2069211000000000, 'ns')
>>> days = x.astype('timedelta64[D]')
>>> days / np.timedelta64(1, 'D')
23
Via StackOverflow.
Leave a comment