Skip to main content
`Ctrl`+`K`

# pandas.Series.to_period

Series.to_period(freq=None, copy=<no_default>)

  Convert Series from DatetimeIndex to PeriodIndex.

  Parameters:
    freq str, default None

      Frequency associated with the PeriodIndex.

    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

      Series with index converted to PeriodIndex.

  See also

  `DataFrame.to_period`

    Equivalent method for DataFrame.

  `Series.dt.to_period`

    Convert DateTime column values.

  Examples

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

  Viewing the index

      >>> s.index
      PeriodIndex(['2023', '2024', '2025'], dtype='period[Y-DEC]')