- API reference
- pandas.PeriodIndex
- pandas.Perio...
pandas.PeriodIndex.strftime#
- PeriodIndex.strftime(*args,**kwargs)[source]#
Convert to Index using specified date_format.
Return an Index of formatted strings specified by date_format, whichsupports the same string format as the python standard library. Detailsof the string format can be found inpython string formatdoc.
Formats supported by the Cstrftime API but not by the python string formatdoc (such as“%R”,“%r”) are not officially supported and should bepreferably replaced with their supported equivalents (such as“%H:%M”,“%I:%M:%S %p”).
Note thatPeriodIndex support additional directives, detailed inPeriod.strftime.
- Parameters:
- date_formatstr
Date format string (e.g. “%Y-%m-%d”).
- Returns:
- ndarray[object]
NumPy ndarray of formatted strings.
See also
to_datetimeConvert the given argument to datetime.
DatetimeIndex.normalizeReturn DatetimeIndex with times to midnight.
DatetimeIndex.roundRound the DatetimeIndex to the specified freq.
DatetimeIndex.floorFloor the DatetimeIndex to the specified freq.
Timestamp.strftimeFormat a single Timestamp.
Period.strftimeFormat a single Period.
Examples
>>>rng=pd.date_range(pd.Timestamp("2018-03-10 09:00"),...periods=3,freq='s')>>>rng.strftime('%B%d, %Y,%r')Index(['March 10, 2018, 09:00:00 AM', 'March 10, 2018, 09:00:01 AM', 'March 10, 2018, 09:00:02 AM'], dtype='object')