pyspark.pandas.DatetimeIndex.strftime

DatetimeIndex.strftime(date_format: str) → pyspark.pandas.indexes.base.Index[source]

Convert to a string 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 the python string format doc.

Parameters
date_formatstr

Date format string (example: “%%Y-%%m-%%d”).

Returns
Index

Index of formatted strings.

See also

normalize

Return series with times to midnight.

round

Round the series to the specified freq.

floor

Floor the series to the specified freq.

Examples

>>> idx = ps.date_range(pd.Timestamp("2018-03-10 09:00"), periods=3, freq='s')
>>> idx.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')