
[英]how to convert Date and time column of dataframe to datetime format of pandas?
[英]How to convert from one date time format to another in pandas?
我有一个Wed Oct 02 10:55:08 BST 2019
,其中日期时间的格式可以是Wed Oct 02 10:55:08 BST 2019
或Wed Oct 02 10:55:08 GMT 2019
。
我希望所有这些日期时间都采用2019-01-10 10:55:08
格式的日期时间,其中时间是 GMT。
谢谢
您需要使用标准库的日期时间并转换为日期时间
from datetime import datetime
df['datecolumn'].apply(lambda x:
datetime.strptime(x, "%a %b %d %I:%M:%S GMT %Y") if 'GMT' in x else x)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.