Skip to main content
`Ctrl`+`K`

# pandas.PeriodIndex.to_timestamp

PeriodIndex.to_timestamp(freq=None, how='start')

  Cast to DatetimeArray/Index.

  Parameters:
    freq str or DateOffset, optional

      Target frequency. The default is ‘D’ for week or longer, ‘s’ otherwise.

    how{‘s’, ‘e’, ‘start’, ‘end’}

      Whether to use the start or end of the time period being converted.

  Returns:
    DatetimeArray/Index

      Timestamp representation of given Period-like object.

  See also

  `PeriodIndex.day`

    The days of the period.

  `PeriodIndex.from_fields`

    Construct a PeriodIndex from fields (year, month, day, etc.).

  `PeriodIndex.from_ordinals`

    Construct a PeriodIndex from ordinals.

  `PeriodIndex.hour`

    The hour of the period.

  `PeriodIndex.minute`

    The minute of the period.

  `PeriodIndex.month`

    The month as January=1, December=12.

  `PeriodIndex.second`

    The second of the period.

  `PeriodIndex.year`

    The year of the period.

  Examples

      >>> idx = pd.PeriodIndex(["2023-01", "2023-02", "2023-03"], freq="M")
      >>> idx.to_timestamp()
      DatetimeIndex(['2023-01-01', '2023-02-01', '2023-03-01'],
      dtype='datetime64[ns]', freq='MS')

  The frequency will not be inferred if the index contains less than three elements, or if the values of index are not strictly monotonic:

      >>> idx = pd.PeriodIndex(["2023-01", "2023-02"], freq="M")
      >>> idx.to_timestamp()
      DatetimeIndex(['2023-01-01', '2023-02-01'], dtype='datetime64[ns]', freq=None)

      >>> idx = pd.PeriodIndex(
      ...     ["2023-01", "2023-02", "2023-02", "2023-03"], freq="2M"
      ... )
      >>> idx.to_timestamp()
      DatetimeIndex(['2023-01-01', '2023-02-01', '2023-02-01', '2023-03-01'],
      dtype='datetime64[ns]', freq=None)