I'm trying to compare Start_Time column and End_Time column that are in SRT timestamp format: 00:00:00,230
I used to_datetime to compare and created a new column to keep track of the difference between the end and start times. Check the answer for more info.
t1 = df['Start_Time']
t2 = df['End_Time']
diff = (t1-t2).astype('timedelta64[s]')
df['Start_Time'] = pd.to_datetime(df['Start_Time'])
df['End_Time'] = pd.to_datetime(df['End_Time'])
But when I run the code above, it tells me this:
TypeError: Cannot convert input [1 00:00:00,230 ... end of list] Name: Start_Time, Length: 123, dtype: object] of type <class 'pandas.core.series.Series'> to Timestamp
Is there a way to compare the two columns while keeping the SRT formatting?
My end goal is this logic:
PS:
I used pd.to_datetime
instead of pd.Timestamp
and created a new column Difference
in the dataframe to know the difference between end and start time.
I also kept a copy of the dataframe dfSRTTime
before using to_datetime so I can keep the original formatting and will be working on editing both for the rest of my code. This will allow me to accurately check for the 5s difference while maintaining original SRT format when I export the file at the end.