[英]Convert from String to Date from UTC format
I have a date in a string format and I can't seem to be able to change it to a date format. 我有一个字符串格式的日期,我似乎无法将其更改为日期格式。 I always get this error: 我总是得到这个错误:
time data '14-08-16 22:22' does not match format '%d-%m-%Y %H:%M:%S' (match)
The data comes from a CSV file and is in UTC format 数据来自CSV文件,采用UTC格式
Here is a Screenshot from the csv file 这是csv文件的屏幕截图
and the code I have done is this 而我所做的代码就是这个
test=pd.to_datetime(myframe['date'], format='%d-%m-%Y %H:%M:%S')
14-08-16 22:22
is not in the format of %d-%m-%Y %H:%M:%S
14-08-16 22:22
的格式不是%d-%m-%Y %H:%M:%S
%Y
is the 4-digit year, %y
is the year's last 2 digits %Y
是4位数年份, %y
是年份的最后2位数字 %H:%M
22:22只是小时和分钟, %H:%M
The format should be %d-%m-%y %H:%M
, see below example: 格式应该是%d-%m-%y %H:%M
,见下面的例子:
>>> from datetime import datetime
>>> datetime.now().strftime("%d-%m-%y %H:%M")
'04-12-16 20:43'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.