简体   繁体   English

如何在 pandas 中将日期格式从 01-Mar-19 更改为 2019-03-01?

[英]How do I change the date format from 01-Mar-19 to 2019-03-01 in pandas?

I have 01-Mar-19 but I need it in 2019-03-01 format I have tried result = pd.to_datetime(dates)我有 19 年 3 月 1 日,但我需要 2019 年 3 月 1 日的格式我已经尝试过 result = pd.to_datetime(dates)

You need to specify the input format for the date with the format parameter:您需要使用format参数指定日期的输入格式:

pd.to_datetime(df["date"], format="%d-%b-%y")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何防止pandas.to_datetime()函数将0001-01-01转换为2001-01-01 - How do I prevent pandas.to_datetime() function from converting 0001-01-01 to 2001-01-01 如何将日期时间列标题(例如 2007-03-01 00:00:00)转换为日期-月-年格式,即 2007-03-01 - How to Convert Datetime column header (e.g. 2007-03-01 00:00:00) into Date-Month-Year format i.e. 2007-03-01 如何让 python 中的 18/Feb/2016 小于 01/Mar/2016? - How do I get 18/Feb/2016 to be less than 01/Mar/2016 in python? 时间数据2019-03-31T01:55:00CET与格式指定的pandas不匹配 - time data 2019-03-31T01:55:00CET doesn't match format specified pandas 值错误:时间数据'2019-03-19T07:01:02Z'与格式'%Y-%m-%dT%H:%M:%S.%fZ'不匹配 - Value Error :Time data '2019-03-19T07:01:02Z' does not match format '%Y-%m-%dT%H:%M:%S.%fZ' 如何将日期格式 01oct2012 更改为 01-10-2012 - how to change a date format 01oct2012 to 01-10-2012 如何从段落中提取日期字符串“2019 年 3 月 11 日 • 3:26AM”并将其转换为 python 中的日期时间格式 (dd/mm/yy) - how do I extract date string "Mar 11, 2019 • 3:26AM" from a paragraph and convert it to date time format (dd/mm/yy) in python 如何从CSV中检测大熊猫中的01年1月1日日期 - How to detect 01-Jan-01 dates in pandas from csv 如何将日期从0001-01-01转换为天数? - How to convert a date to a number of days from 0001-01-01? Python - Pandas - 将格式为 2018-01-01 的日期列转换为时间戳的字符串版本 - Python - Pandas - Convert date column in format 2018-01-01 to string version of timestamp
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM