pandas.DatetimeIndex.to_period
pandas 3.1.1 · Index objects · method
Represent datetimes as periods at the selected frequency.
Call syntax
DatetimeIndex.to_period(freq=None)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. |
Returns
PeriodArray/PeriodIndex