For the below log data assume each row will be coming at once as…
Question Answered step-by-step For the below log data assume each row will be coming at once as… For the below log data assume each row will be coming at once as the inputsession_id,step,time100, 1, 3 100, 2, 4100, 3, 6100, 4, 10101, 1, 2101, 2, 4 we need to calculate average time taken for each step in python Example:when we receive100, 1, 3 the average time taken at this point for step 1 is {1:0,2:0,3:0,4:0} 100, 2, 4 the average time taken for step 2 is 0 and time taken for step 1 is ( 4-3) and average time taken is (4-3)/1 (since we have only one session 100 so far) result : {1:1:2,0,3:0,4:0} 100, 3, 6 the average time taken for step 3 is 0 and time taken for step2 is (6-4) and average time taken is. (6-4)/1 (since we have only one sesion 100 so far) result {1:1,2:2:3:0,4:0} 100, 4, 10 the average time taken for step 4 is 0 and time taken for step3 is (10-6) and average time taken is (10-6)/1 (since we have only one session 100 so fat( result is {1:1,2:2,3:4,4:0} 101, 1, 2 the average time for any step does not change at this step but we need to note that we received a new session 101, 2, 3 the average time taken for step 2 is 0 and time taken for step 1 is ( 4-3)[ this is from session 100] and for current session it is (4-2) and average time taken is (4-3) + (4-2) / 2 (since we have two sessions so far 100 and 101) result is {1:1.5 , 2:3 ,3:4,4:0} we need to return the result dict at row of this log data. The order of steps is not guaranteed.example step4 for session 100 came before step3 of session 100. so need to calculate avg time at that appropriate steps. 100,1,31 :result {1:0,2:0,3:0,4:0}100,2,41 :{1:10, 2:0, 3:0 ,4:0}101,1, 21 :{1:10, 2:0, 3:0 ,4:0}100,4,40 :{1:10, 2:0, 3:0 ,4:0}101,2,41 : {1:15 ,2:0,3:0 , 4:0}100,3,31 : {1:15 ,2:10,3:9 , 4:0} Computer Science Engineering & Technology Python Programming HOME SCHOOL MATH Share QuestionEmailCopy link Comments (0)


