I have a pandas dataframe as follows
Dev_id Time
88345 13:40:31
87556 13:20:33
88955 13:05:00
..... ........
85678 12:15:28
The above dataframe has 83000 rows. I want to take time difference between two consecutive rows and keep it in a separate column. The desired result would be
Dev_id Time Time_diff(in min)
88345 13:40:31 20
87556 13:20:33 15
88955 13:05:00 15
I have tried df['Time_diff'] = df['Time'].diff(-1)
but getting error as shown below
TypeError: unsupported operand type(s) for -: 'datetime.time' and 'datetime.time'
How to solve this
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…