sh1ng sh1ng - 5 months ago 21
Python Question

python pandas parse datetime string with months names

Can someone point me to a format or a code snippet to parse date in format like

04SEP12:00:00:00


That
%dd%mm%YY:%HH:%MM:%SS
doesn't work.

Answer

Use format string: '%d%b%y:%H:%M:%S' and pass this as the format for to_datetime, you can find the format options in the docs:

In [73]:

pd.to_datetime('04SEP12:00:00:00', format='%d%b%y:%H:%M:%S')
Out[73]:
Timestamp('2012-09-04 00:00:00')
Comments