I want to subtract the time between 2 column: I have been using this:
row['window'] = datetime.datetime.strptime(row['Time'], '%H:%M:%S.%f') - datetime.datetime.strptime(row['announcement_time'], '%H:%M:%S')
This works and gives a result that look like this:
window
-1 day, 23:29:00
-1 day, 23:29:05
-1 day, 23:29:10
-1 day, 23:29:15
-1 day, 23:29:20
-1 day, 23:29:25
However, I only want the time difference i.e. - 00:00:30. I have tried :
row['window'] = datetime.datetime.strptime(row['Time'], '%H:%M:%S.%f').time() - datetime.datetime.strptime(row['announcement_time'], '%H:%M:%S').time()
But this gives an error :
TypeError: unsupported operand type(s) for -: 'datetime.time' and 'datetime.time'
I have also tried .hour, .minute and .second but does not work very well. Can someone please help.Thanks