我有一个类似于这样的DataFrame
:
score num_participants
0 20
1 15
2 5
3 10
4 12
5 15
我需要找到参与人数中分数大于或等于当前行score
的数量:
score num_participants num_participants_with_score_greater_or_equal
0 20 77
1 15 57
2 5 42
3 10 37
4 12 27
5 15 15
所以,我想要对当前行及其以下所有行进行求和。数据大约有5000行,所以我无法通过索引手动设置它。cumsum
不能解决这个问题,我也不确定是否有简单的方法可以实现。我已经花了相当多的时间尝试解决这个问题,所以希望能得到任何帮助。