I have a pandas dataframe which has a 'Time' column which has rows like 13:50:00
(it is of type string).Now I have a time of the format and value 21:21:21
.I want to subtract the two.
Now I did abs(datetime.strptime(a, '%H:%M:%S').time()- recording_start_time)) which is still giving me the error
print(abs(datetime.strptime(a, '%H:%M:%S').time()- recording_start_time))
TypeError: unsupported operand type(s) for -: 'datetime.time' and 'datetime.time'
My code looks like-
min_time_diff = abs(df3.loc[cond & cond2 ]['Time'].apply(lambda x: datetime.strptime(x, '%H:%M:%S').time()- recording_start_time))
so I need a cleaner solution than the subtract two times in python provided here as it is searching through all the rows in 'Time' column and subtracting from a fixed value.