I'm trying to subtract two columns in a CSV to create a 3rd column "Duration" End-Time - Start_time
Each row corresponds to a User Id as well.
I can create a csv file with just the Duration column but i rather redirect it back to the original csv.
The format of these times for e.g is like 2016-11-12 01:25:24+00 - 2016-11-12 01:25:20+00
So far I have done this
start_stop_sessions = pd.read_csv("start_stop_sessions.csv", parse_dates
['time_x', 'time_y'])
start_stop_sessions['time_delta'] = start_stop_sessions.time_y.values -
start_stop_sessions.time_x.values
Duration = (start_stop_sessions.time_delta)
print (Duration)
sys.stdout = open('Duration.csv', 'w')
Durationlist = ("Duration.csv")
max_value = max(Durationlist)
min_value = min(Durationlist)
Am I doing this right?
TEST DATA
time_x, anonymous_id, time_y
2016-11-20 18:35:57+00, 1, 2016-11-20 19:03:31+00
2016-11-21 19:33:06+, 2, 2016-11-21 19:45:47+00
2016-11-21 19:22:52+00, 3, 2016-11-21 19:26:02+00
1) I would need to create a 4th column Duration
2) List of MIN, MAX, AVG for this duration column