Skip to content Skip to sidebar Skip to footer

How To Conver 'sat Feb 02 12:50:00 Ist 2019' To Regular Datetime In 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

Solution 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

Post a Comment for "How To Conver 'sat Feb 02 12:50:00 Ist 2019' To Regular Datetime In Python?"