熊猫-累计金额

时间:2018-09-23 04:12:50

标签: pandas

我有一个数据框,

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

0 个答案:

没有答案