pandas.Series.dt.strftime#
- Series.dt.strftime(*args, **kwargs)[源代码]#
使用指定的Date_Format转换为索引。
返回由DATE_FORMAT指定的格式化字符串的索引,它支持与Python标准库相同的字符串格式。有关字符串格式的详细信息,请参阅 python string format doc 。
C++支持的格式 strftime API,而不是通过python字符串格式的文档(如 "%R" , "%r" )不受官方支持,最好用其受支持的等价物(如 "%H:%M" , "%I:%M:%S %p" )。
请注意, PeriodIndex 支持其他指令,详细信息请参阅 Period.strftime 。
- 参数
- date_format应力
日期格式字符串(例如“%Y-%m-%d”)。
- 退货
- ndarray [对象]
格式化字符串的NumPy ndarray。
参见
to_datetime
将给定参数转换为DateTime。
DatetimeIndex.normalize
返回时间为午夜的DatetimeIndex。
DatetimeIndex.round
将DatetimeIndex舍入为指定的频率。
DatetimeIndex.floor
将DatetimeIndex设置为指定的频率。
Timestamp.strftime
设置单个时间戳的格式。
Period.strftime
设置单个句点的格式。
示例
>>> 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')