I have a data frame with two columns representing the departure and arrival times of an aircraft. Each element in these columns is datetime.time
object. Each column e.g. df['CRS_ARR_TIME']
is series and looks as follows:
0 15:10:00
1 16:15:00
2 15:12:00
3 15:18:00
4 17:30:00
...
I cannot find the duration of the flight since whenever subtracting the two columns I get an error. I also tried to use to_timedelta:
df_subset[['CRS_ARR_TIME','CRS_DEP_TIME']] = df_subset[['CRS_ARR_TIME','CRS_DEP_TIME']].apply(pd.to_timedelta)
but it does not work because I get:
Invalid type for timedelta scalar: <class 'datetime.time'>
Would be thankful for any suggestions.