Pandas Calculate Time Difference
I have date data where I am trying to calculate different in second between successive rows. My data date 0 2014-05-01 18:47:05 1 2014-05-01 18:47:25 2 2014-05-02 18:47:45 3
Solution 1:
Use diff
and dt.seconds
df.date.diff().dt.seconds
df.assign(seconds=df.date.diff().dt.seconds)
date seconds
0 2014-05-01 18:47:05 NaN
1 2014-05-01 18:47:25 20.0
2 2014-05-02 18:47:45 20.0
3 2014-05-02 18:48:05 20.0
4 2014-05-02 18:48:55 50.0
Post a Comment for "Pandas Calculate Time Difference"