如何基于多重条件创建新列

时间:2019-10-24 14:50:53

标签: python python-3.x pandas

我有pandas datframe df,其列为Speed,fall Rate和Hit Rate。

我想根据下面描述的条件将这3列分为几类(为每个列创建新的类Columns)。如果值落在该范围内。

Speed    Speed Class Fall Rate  Fall Class  Hit rate       Hit Class
<=38        Green    <2.5       Green       0 <=0.5        Green
>39 <= 74   Green  >2.5 <=7.6   Green     >0.5 <=1.2       Green
>74 <=117   Yellow    >7.6 <=10 Yellow      >1.2 <=1.4     Yellow
>117        Red     >10         Red      >1.4              Red

样本输入

enter image description here

预期产量

enter image description here

0 个答案:

没有答案
相关问题