divide a column based on groupby or looping conditions in pandas
问题 I have a data frame as shown below B_ID No_Show Session slot_num Patient_count 1 0.2 S1 1 1 2 0.3 S1 2 1 3 0.8 S1 3 1 4 0.3 S1 3 2 5 0.6 S1 4 1 6 0.8 S1 5 1 7 0.9 S1 5 2 8 0.4 S1 5 3 9 0.6 S1 5 4 12 0.9 S2 1 1 13 0.5 S2 1 2 14 0.3 S2 2 1 15 0.7 S2 3 1 20 0.7 S2 4 1 16 0.6 S2 5 1 17 0.8 S2 5 2 19 0.3 S2 5 3 where No_Show = Probability of no show Assume that threshold probability = 0.2 Duration for each slot = 30 (minutes) From the above I would like calculate below data frame Step1 sort the