pandas.TimedeltaIndex.asi8#
- property TimedeltaIndex.asi8[source]#
Return Integer representation of the values.
For
DatetimeIndexandTimedeltaIndex, the values are the number of time units (determined by the index resolution) since the epoch. ForPeriodIndex, the values are ordinals.- Returns:
- numpy.ndarray
An ndarray with int64 dtype.
See also
Index.valuesReturn an array representing the data in the Index, using native types (datetime64, timedelta64) rather than int64.
Index.to_numpyReturn a NumPy ndarray of the index values.
Examples
For
DatetimeIndexwith default microsecond resolution:>>> idx = pd.DatetimeIndex(["2023-01-01", "2023-01-02"], dtype="datetime64[us]") >>> idx.asi8 array([1672531200000000, 1672617600000000])
For
TimedeltaIndexwith millisecond resolution:>>> idx = pd.TimedeltaIndex(["1 day", "2 days"], dtype="timedelta64[ms]") >>> idx.asi8 array([ 86400000, 172800000])
For
PeriodIndex:>>> idx = pd.PeriodIndex(["2023-01", "2023-02", "2023-03"], freq="M") >>> idx.asi8 array([636, 637, 638])