Reputation: 59
I have a column in pandas dataframe in the format 20151028 193133
I want to convert this string into a date time format like 2015-10-28 19:26:48
How can I do this?
Upvotes: 2
Views: 96
Reputation: 863531
Try to_datetime
and parameter format
docs:
print df
col
0 20151028 193133
1 20151028 193133
2 20151028 193133
df['col'] = pd.to_datetime(df['col'], format="%Y%m%d %H%M%S")
print df
col
0 2015-10-28 19:31:33
1 2015-10-28 19:31:33
2 2015-10-28 19:31:33
Upvotes: 2