我几乎没有什么工作条件,比如:
1. if employment is 'salaried' or 'business' and annual income is '<=10 lakhs' and stp flagging is 'NON STP' then result should be 'No Issue'
2. if employment is 'salaried' or 'business' and annual income is '>10 lakhs' and stp flagging is 'STP' then result should be 'No Issue'
3. if employment is 'salaried' or 'business' and annual income is '>10 lakhs' and stp flagging is 'NON STP' then result should be 'Issue'
4. if employment is 'salaried' or 'business' and annual income is '<=10 lakhs' and stp flagging is 'STP' then result should be 'Issue'
我试过这个密码-
df['Result'] = 'Null'
df['Result']=np.where((df['Employment']=='Salaried')|
(df['Employment']=='Business')&
(df['Annual income of policy owner']=='<= 10 lakh')&
(df['STP flagging'] == 'NON STP'),'No Issue','')
df['Result']=np.where((df['Employment']=='Salaried')|
(df['Employment']=='Business')&
(df['Annual income of policy owner']=='>10 lakh')&
(df['STP flagging'] == 'STP'),'No Issue','')
df['Result']=np.where((df['Employment']=='Salaried')|
(df['Employment']=='Business')&
(df['Annual income of policy owner']=='>10 lakh')&
(df['STP flagging'] == 'NON STP'),'Issue','')
df['Result']=np.where((df['Employment']=='Salaried')|
(df['Employment']=='Business')&
(df['Annual income of policy owner']=='<= 10 lakh')&
(df['STP flagging'] == 'STP'),'Issue','')
但只有最后一行有效,我需要为每个条件指定结果。请帮我修改代码
我认为您没有明确定义您的要求/条件。您可以使用
numpy.where
尝试以下内容:相关问题 更多 >
编程相关推荐