I am facing problem while finding the duration. The df is
data ={
'initial_time': ['2019-05-21 22:29:55','2019-10-07 17:43:09','2020-12-13 23:53:00','2018-04-17 23:51:23','2016-08-31 07:40:49'],
'final_time' : ['2019-05-22 01:10:30','2019-10-07 17:59:09','2020-12-13 00:30:10','2018-04-18 01:01:23','2016-08-31 08:45:49'],
'duration' : [0,0,0,0,0]
}
df =pd.DataFrame(data)
df
Output:
initial_time final_time duration
0 2019-05-21 22:29:55 2019-05-22 01:10:30 0
1 2019-10-07 17:43:09 2019-10-07 17:59:09 0
2 2020-12-13 23:53:00 2020-12-13 00:30:10 0
3 2018-04-17 23:51:23 2018-04-18 01:01:23 0
4 2016-08-31 07:40:49 2016-08-31 08:45:49 0
The output I'm expecting is total duration
i.e final_time - initial_time
.
Note : It consist values whose initial and final time comes on different dates(row 1).