Skip to main content
`Ctrl`+`K`

# pandas.arrays.DatetimeArray

class pandas.arrays.DatetimeArray(data, dtype=None, freq=None, copy=False)

  Pandas ExtensionArray for tz-naive or tz-aware datetime data.

  Warning

  DatetimeArray is currently experimental, and its API may change without warning. In particular, `DatetimeArray.dtype` is expected to change to always be an instance of an `ExtensionDtype` subclass.

  Parameters:
    data Series, Index, DatetimeArray, ndarray

      The datetime data.

      For DatetimeArray values (or a Series or Index boxing one), dtype and freq will be extracted from values.

    dtype numpy.dtype or DatetimeTZDtype

      Note that the only NumPy dtype allowed is ‘datetime64[ns]’.

    freq str or Offset, optional

      The frequency.

    copy bool, default False

      Whether to copy the underlying array of values.

  Attributes

  None |

  Methods

  None |

  See also

  `DatetimeIndex`

    Immutable Index for datetime-like data.

  `Series`

    One-dimensional labeled array capable of holding datetime-like data.

  `Timestamp`

    Pandas replacement for python datetime.datetime object.

  `to_datetime`

    Convert argument to datetime.

  `period_range`

    Return a fixed frequency PeriodIndex.

  Examples

      >>> pd.arrays.DatetimeArray._from_sequence(
      ...     pd.DatetimeIndex(["2023-01-01", "2023-01-02"], freq="D")
      ... )
      <DatetimeArray>
      ['2023-01-01 00:00:00', '2023-01-02 00:00:00']
      Length: 2, dtype: datetime64[us]