PASUMPON V N
PASUMPON V N

Reputation: 1186

update data frame with another data frame only if the column contains specific value

I have two data frames df1, df2.

I want to update the df1 with value "yes" in the same row number and column number as it is in the df2,

I have attached the image for your reference.

I am using python and pandas.

Thanksenter image description here

Upvotes: 0

Views: 17

Answers (1)

BENY
BENY

Reputation: 323226

Using where and combine_first

df3=df2.where(df2=='Yes').combine_first(df1)

Upvotes: 1

Related Questions