pandas.PeriodIndex.strftime#

PeriodIndex.strftime(date_format)[source]#

Convert to Index using specified date_format.

Return an Index of formatted strings specified by date_format, which supports the same string format as the python standard library. Details of the string format can be found in python string format doc. Period objects additionally support several directives not covered there, detailed in Period.strftime().

Parameters:
date_formatstr

Date format string (e.g. ā€œ%Y-%m-%dā€).

Returns:
Index

Index of formatted strings.

See also

to_datetime

Convert the given argument to datetime.

Period.strftime

Format a single Period.

Examples

>>> idx = pd.PeriodIndex(["2023-01", "2023-02", "2023-03"], freq="M")
>>> idx.strftime("%B %d, %Y")
Index(['January 31, 2023', 'February 28, 2023', 'March 31, 2023'], dtype='str')