VOOZH about

URL: https://www.geeksforgeeks.org/pandas/pandas-series-dt-to_period/

⇱ Pandas Series dt.to_period() Method | Convert DateTime to Period Format - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Pandas Series dt.to_period() Method | Convert DateTime to Period Format

Last Updated : 11 Jul, 2025

The Pandas dt.to_period() method converts the underlying data of the given Series object to PeriodArray/Index at a particular frequency.

It is used to convert a DateTime series to a period series with a specific frequency, such as daily, monthly, quarterly, or yearly periods.

Example

Output:
👁 DateTime converted to period format

Syntax

Syntax: Series.dt.to_period(freq)

Parameter

  • freq : string or Offset, optional

Returns: The original Series cast to PeriodArray/Index at the specified frequency 

How to Convert a Pandas DateTime Series to a Period Series

To convert a Pandas DateTime Series to a Period series we use the dt.to_period() method of the Pandas library in Python. 

Let us understand it better with an example:

Example

Use the dt.to_period() function to cast the underlying data of the given series object to Index at two-year frequency. 

Output:

👁 datetime series created

Now we can use dt.to_period() method to convert it to period format

Output:

👁 converted datetime series in period format

As we can see in the output, the Series.dt.to_period() function has successfully cast the data to the target frequency. 

Comment

Explore