I have a df that looks like this:
event response. duration
0 5 1.1
0 4 0.5
1 5 3.2
0 6 1.2
0 5 2.1
0 5 3.2
1 5 0.9
0 4 1.1
0 4 1.2
0 4 3.1
0 5 0.4
0 5 0.9
If df.event indicates 1, then the event of interest has occurred. If the event occurred, then I want to see what the response for the next 2 rows. In the next 2 rows, I want to select the response with the greatest duration. I want this information created in a new column, responseType which holds NaN if the event is 0 and the max duration response if event is 1 over the next 2 rows.
It should look like this:
event response. duration. responseType
0 5 1.1 NaN
0 4 0.5 NaN
1 5 3.2 NaN
0 6 2.2 6
0 5 1.1 NaN
0 5 3.2 NaN
1 5 0.9 NaN
0 4 1.1 NaN
0 4 1.2 4
0 4 3.1 NaN
0 5 0.4 NaN
0 5 0.9 NaN