Skip to main content
`Ctrl`+`K`

# pandas.Series.to_timestamp

Series.to_timestamp(freq=None, how='start', copy=<no_default>)

  Cast to DatetimeIndex of Timestamps, at beginning of period.

  This can be changed to the end of the period, by specifying how=”e”.

  Parameters:
    freq str, default frequency of PeriodIndex

      Desired frequency.

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

      Convention for converting period to timestamp; start of period vs. end.

    copy bool, default False

      This keyword is now ignored; changing its value will have no impact on the method.

      Deprecated since version 3.0.0: This keyword is ignored and will be removed in pandas 4.0. Since pandas 3.0, this method always returns a new object using a lazy copy mechanism that defers copies until necessary (Copy-on-Write). See the user guide on Copy-on-Write for more details.

  Returns:
    Series with DatetimeIndex

      Series with the PeriodIndex cast to DatetimeIndex.

  See also

  `Series.to_period`

    Inverse method to cast DatetimeIndex to PeriodIndex.

  `DataFrame.to_timestamp`

    Equivalent method for DataFrame.

  Examples

      >>> idx = pd.PeriodIndex(["2023", "2024", "2025"], freq="Y")
      >>> s1 = pd.Series([1, 2, 3], index=idx)
      >>> s1
      2023    1
      2024    2
      2025    3
      Freq: Y-DEC, dtype: int64

  The resulting frequency of the Timestamps is YearBegin

      >>> s1 = s1.to_timestamp()
      >>> s1
      2023-01-01    1
      2024-01-01    2
      2025-01-01    3
      Freq: YS-JAN, dtype: int64

  Using freq which is the offset that the Timestamps will have

      >>> s2 = pd.Series([1, 2, 3], index=idx)
      >>> s2 = s2.to_timestamp(freq="M")
      >>> s2
      2023-01-31    1
      2024-01-31    2
      2025-01-31    3
      Freq: YE-JAN, dtype: int64