How to convert a string to timestamp in pandas

Viewed 22430

I am having the following dataset

    OPEN TIME  CLOSE TIME
0   09:44:00   10:07:00
1   10:07:00   11:01:00
2   11:05:00   13:05:00

But here the timestamps are in string format, how can I convert them to time format? please help me!

1 Answers

to_datetime

df['Open'] = pd.to_datetime(df['OPEN TIME'],format= '%H:%M:%S' ).dt.time
df['Close'] = pd.to_datetime(df['CLOSE TIME'],format= '%H:%M:%S' ).dt.time
Related