How to conver 'Sat Feb 02 12:50:00 IST 2019' to regular datetime in python?

与世无争的帅哥 提交于 2020-06-29 03:41:07

问题


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?


回答1:


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)

This prints:

2019-02-02 12:50:00


来源:https://stackoverflow.com/questions/62370051/how-to-conver-sat-feb-02-125000-ist-2019-to-regular-datetime-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!