python pandas parse datetime string with months names python pandas parse datetime string with months names pandas pandas

python pandas parse datetime string with months names


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')


Another way is simply do:

pd.to_datetime("May 15, 2016", infer_datetime_format=True)>>>Timestamp('2016-05-15 00:00:00')


As another example,

pd.to_datetime("May 15, 2016", format="%b %d, %Y")>>>Timestamp('2016-05-15 00:00:00')

Use %b for the month names.