Skip to main content
`Ctrl`+`K`

# pandas.DatetimeIndex.asi8

property DatetimeIndex.asi8

  Return Integer representation of the values.

  For `DatetimeIndex` and `TimedeltaIndex`, the values are the number of time units (determined by the index resolution) since the epoch. For `PeriodIndex`, the values are ordinals.

  Returns:
    numpy.ndarray

      An ndarray with int64 dtype.

  See also

  `Index.values`

    Return an array representing the data in the Index, using native types (datetime64, timedelta64) rather than int64.

  `Index.to_numpy`

    Return a NumPy ndarray of the index values.

  Examples

  For `DatetimeIndex` with default microsecond resolution:

      >>> idx = pd.DatetimeIndex(["2023-01-01", "2023-01-02"], dtype="datetime64[us]")
      >>> idx.asi8
      array([1672531200000000, 1672617600000000])

  For `TimedeltaIndex` with 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])