2

I have a pandas dataframe with dates in the following format: 01JAN2015:00:00:00

I want to convert these dates to the datetime format. I tried some variations presented in the forum but could not do it.

Can someone, please, help me with that?

Thanks a lot,

Rodrigo.

1 Answers1

1

Demo:

In [85]: df
Out[85]:
                   ts
0  01JAN2015:00:00:00
1  11FEB2015:13:13:13

In [86]: df['ts'] = pd.to_datetime(df['ts'], format='%d%b%Y:%H:%M:%S', errors='coerce')

In [87]: df
Out[87]:
                   ts
0 2015-01-01 00:00:00
1 2015-02-11 13:13:13

In [88]: df.dtypes
Out[88]:
ts    datetime64[ns]
dtype: object
MaxU - stand with Ukraine
  • 205,989
  • 36
  • 386
  • 419