简体   繁体   English

基于多种条件的Pandas Data Frame isnan更新

[英]pandas Data Frame isnan update based on multiple condition

How to update the records based on the multiple condition 如何根据多个条件更新记录

I have dataframe with below columns 我在下面的列中有数据框

Married 已婚

Applicant income 申请人收入

Co-applicant income 共同申请人收入

I want to update the nan field in married by checking the Applicant income greater than 0 and Co-applicant income greater than 0 我想通过检查申请人收入大于0和共同申请人收入大于0来更新已婚的nan字段

Can you try with this. 你可以尝试一下吗?

condition=(df['ApplicantIncome']>0)&(df['CoapplicantIncome'] >0 ) 
condition2=(df['Married'].isnull()) 
criteria = condition & condition2
df.loc[criteria,'Married']='Yes' 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM