我有一个数据框,
peopleLimit = 4
df = pd.DataFrame([['A',1,1],['B',1,4],['C',1,1]],columns=['class','persons','req'])
class persons req
0 A 1 1
1 B 1 4
2 C 1 1
req
表示现在class
中可以容纳的人数,但是(A + B + C)类人数却很少<= {peopleLimit
所以我怎么得到答案结果,
class persons
0 A 1
1 B 2
2 C 1
,如果
df = pd.DataFrame([['A',1,2],['B',2,1],['C',1,1]],columns=['class','persons','req'])
class persons req
0 A 1 2
1 B 2 1
2 C 1 1
新商品是
class persons
0 A 2
1 B 1
2 C 1