Anandaraj Pandian
Anandaraj Pandian

Reputation: 47

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

Upvotes: 1

Views: 42

Answers (1)

Vinoth96
Vinoth96

Reputation: 353

Can you try with this.

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

Upvotes: 2

Related Questions