如何将``Sat Feb 02 12:50:00 IST 2019''转换为python中的常规日期时间? [英] How to conver 'Sat Feb 02 12:50:00 IST 2019' to regular datetime in python?

查看:183
本文介绍了如何将``Sat Feb 02 12:50:00 IST 2019''转换为python中的常规日期时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将数据框'Sat Feb 02 12:50:00 IST 2019'的此列转换为常规的日期时间格式,即(2019-05-02 12:00: 00)在python中

I am trying to convert this column of my dataframe 'Sat Feb 02 12:50:00 IST 2019' to regular datetime format ie(2019-05-02 12:00:00) in python

我如何将所有行转换为这种格式?

How do i convert all the rows to this format?

推荐答案

假设您不需要日期时间Python对象即可识别时区,则可以使用 strptime 如下:

Assuming you don't need your datetime Python object to be timezone aware, you could just use strptime as follows:

dt = "Sat Feb 02 12:50:00 IST 2019"
out = datetime.strptime(dt, "%a %b %d %H:%M:%S IST %Y")
print(out)

此打印件:

2019-02-02 12:50:00

这篇关于如何将``Sat Feb 02 12:50:00 IST 2019''转换为python中的常规日期时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆