subtract 1 from next cumsum if current cumsum more than a particular value - pandas or numpy
- 阅读更多 关于 subtract 1 from next cumsum if current cumsum more than a particular value - pandas or numpy
问题 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.