I am using python to calculate time intervals between two events. Each event has a 'beginning time' and an 'ending time.' I have found the difference between the two in a new column, 'interval', but have negative values when the beginning and ending time are on different days (for instance begin 23:46:00 and end 00:21:00 gives -23:25:00). I would like to create an if-statement to run through the 'interval' column and add 24 hours to any negative values. However, I have had problems with adding 24 hours to the 'interval' values. Currently my 'interval' dtype=timedelta64[ns].
Here is a little bit of the table to clarify the problem:
CallDate BeginningTime EndingTime Interval
75 1/8/2009 1900-01-01 07:49:00 1900-01-01 08:19:00 00:30:00
76 1/11/2009 1900-01-01 14:37:00 1900-01-01 14:59:00 00:22:00
77 1/9/2009 1900-01-01 09:29:00 1900-01-01 09:56:00 00:27:00
78 1/11/2009 1900-01-01 09:20:00 1900-01-01 10:13:00 00:53:00
79 1/16/2009 1900-01-01 15:11:00 1900-01-01 15:50:00 00:39:00
80 1/17/2009 1900-01-01 22:52:00 1900-01-01 23:26:00 00:34:00
81 1/19/2009 1900-01-01 05:48:00 1900-01-01 06:32:00 00:44:00
82 1/20/2009 1900-01-01 23:46:00 1900-01-01 00:21:00 -23:25:00
83 1/20/2009 1900-01-01 21:29:00 1900-01-01 22:08:00 00:39:00
84 1/23/2009 1900-01-01 07:33:00 1900-01-01 07:55:00 00:22:00
85 1/30/2009 1900-01-01 19:33:00 1900-01-01 20:01:00 00:28:00
Aucun commentaire:
Enregistrer un commentaire