I have two df columns with string values:
df['starttime'] df['endtime']
0 2015-10-06 18:35:33 0 2015-10-06 18:35:58
1 2015-10-08 17:51:21.999000 1 2015-10-08 17:52:10
2 2015-10-08 20:51:55.999000 2 2015-10-08 20:52:21
3 2015-10-05 15:16:49.999000 3 2015-10-05 15:17:00
4 2015-10-05 15:16:53.999000 4 2015-10-05 15:17:22
5 2015-10-05 15:17:11.999000 5 2015-10-05 15:17:23.999000
Id like to calculate the difference between these two columns
here is what I tried but failed:
(df['starttime']-df['endtime']).astype('timedelta64[h]'))
unsupported operand type(s) for -: 'str' and 'str'
I thought astype would convert the str to timedelta?