pandas.Series.to_period
pandas 3.1.1 · Series and accessors · method
Convert the Series DatetimeIndex to a PeriodIndex, preserving the Series values.
Call syntax
Series.to_period(freq=None, copy=…)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
freq |
Optional Positional or keyword Default None |
str Specify the frequency or offset, such as "D" for a day or "MS" for a calendar month start. |
copy |
Optional Positional or keyword |
bool Control whether data is copied where the API supports that choice. |
Returns
Series