用法:
Series.dt.strftime(*args, **kwargs)
使用指定的date_format 轉換為索引。
返回由date_format指定的格式化字符串的索引,它支持與python標準庫相同的字符串格式。字符串格式的詳細信息可以在 python 字符串格式文檔中找到。
- date_format:str
日期格式字符串(例如“%Y-%m-%d”)。
- ndarray[對象]
格式化字符串的 NumPy ndarray。
參數:
返回:
例子:
>>> 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')
相關用法
- Python pandas.Series.dt.second用法及代碼示例
- Python pandas.Series.dt.day_name用法及代碼示例
- Python pandas.Series.dt.is_year_end用法及代碼示例
- Python pandas.Series.dt.weekday用法及代碼示例
- Python pandas.Series.dt.to_pydatetime用法及代碼示例
- Python pandas.Series.dt.tz_localize用法及代碼示例
- Python pandas.Series.dt.is_leap_year用法及代碼示例
- Python pandas.Series.dt.is_quarter_start用法及代碼示例
- Python pandas.Series.dt.tz_convert用法及代碼示例
- Python pandas.Series.dt.round用法及代碼示例
- Python pandas.Series.dt.nanosecond用法及代碼示例
- Python pandas.Series.dt.to_period用法及代碼示例
- Python pandas.Series.dt.ceil用法及代碼示例
- Python pandas.Series.dt.hour用法及代碼示例
- Python pandas.Series.dt.day用法及代碼示例
- Python pandas.Series.dt.is_month_end用法及代碼示例
- Python pandas.Series.dt.is_month_start用法及代碼示例
- Python pandas.Series.dt.year用法及代碼示例
- Python pandas.Series.dt.normalize用法及代碼示例
- Python pandas.Series.dt.day_of_week用法及代碼示例
注:本文由純淨天空篩選整理自pandas.pydata.org大神的英文原創作品 pandas.Series.dt.strftime。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。