xorbits.pandas.Series.to_period#

Series.to_period(freq: str | None = None, copy: bool | None = None) Series[source]#

Convert Series from DatetimeIndex to PeriodIndex.

Parameters
  • freq (str, default None) – Frequency associated with the PeriodIndex.

  • copy (bool, default True) – Whether or not to return a copy.

Returns

Series with index converted to PeriodIndex.

Return type

Series

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: A-DEC, dtype: int64

Viewing the index

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

Warning

This method has not been implemented yet. Xorbits will try to execute it with pandas.

This docstring was copied from pandas.core.series.Series.