I have a data frame as shown below
B_ID Session no_show cumulative_no_show
1 s1 0.4 0.4
2 s1 0.6 1.0
3 s1 0.2 1.2
4 s1 0.1 1.3
5 s1 0.4 1.7
6 s1 0.2 1.9
7 s1 0.3 2.2
10 s2 0.3 0.3
11 s2 0.4 0.7
12 s2 0.3 1.0
13 s2 0.6 1.6
14 s2 0.2 1.8
15 s2 0.5 2.3
where cumulative_no_show is the cumulative sum of no_show.
From the above I would like to create a new column called u_no_show based on below condition.
Whenever cumulative_no_show >= 0.8, then subtract 1 from next cumulative_no_show. and so on.
Expected Output:
B_ID Session no_show cumulative_no_show u_no_show
1 s1 0.4 0.4 0.4
2 s1 0.6 1.0 1.0
3 s1 0.2 1.2 0.2
4 s1 0.1 1.3 0.3
5 s1 0.4 1.7 0.7
6 s1 0.2 1.9 0.9
7 s1 0.3 2.2 0.2
10 s2 0.3 0.3 0.3
11 s2 0.4 0.7 0.7
12 s2 0.3 1.0 1.0
13 s2 0.6 1.6 0.6
14 s2 0.2 1.8 1.8
15 s2 0.5 2.3 0.3