Hi i have a dataframe df with column trans_dt
I would like to convert this to date format for all rows. This is currently of object type
can someone help.
20 14022022
20 14022022
20 14022022
20 14022022
20 14022022
...
20 14022022
20 14022022
20 14022022
20 14022022
20 14022022
Name: trans_dt, Length: 1939, dtype: object```
CodePudding user response:
Use the to_datetime function, specifying a format to match your data.
df['trans_dt'] = pd.to_datetime(df['trans_dt'], format='%d%b%Y:%H:%M:%S.%f')