Python计数有很多条件

时间:2019-10-21 20:39:29

标签: python pandas numpy dataframe conditional-statements

我需要根据“计算”和“订单”列对值进行计数。但是我有几个这样的条件:

Packed Size  Minimum Quantity   Active  Calculation  Order     Output(Count)
     7               6             1         7         7          0        #it is ok, calculation=order. no need to count
     3               6             0         6         6          1        #"calculation = order" but it shouldn't have any order. because not active day even if there is a calculation. so output is 1.
     3               4             1         3         3          1        #it shouldn't have any order. because calculation and order is lower than minimum quantity. so output is 1.
     4               3             1         4         3          1        #calculation is greater than minimum quantity and active is 1 and multiple of the packed size. so, order should be equal to calculation. output is 1.
     4               3             1         3         4          0        #calculation is lower than order and active is 1. but order must be multiples of 4 and 4 due to packed size column and greater than minimum quantity. so, output is 0. it is ok.
     5               4             1         7         7          1        #calculation and order is equal, active day and they are greater than minimum quantity. but they are not multiples of 5 or 5 due to packed size. so, output is 1.       

如何获得满足此条件的优雅代码?您能帮忙吗?

0 个答案:

没有答案