Quantcast
Channel: Changing a value of first data frame for rows that match with 2nd data frame in python - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Changing a value of first data frame for rows that match with 2nd data frame in python

$
0
0

For example, if first data frame df1 is:

'a''b''value'0     1   2     11     2   3     1

and second data frame df2 is

'a''b'0     1   2

I would like to get something like

'a''b''value'0     1   2     01     2   3     1

For all the rows in df1(excluding 'value' column) that match the rows in df2, I would like to change the 'value' column of these rows in df1 from 1 to 0. I can find the common rows by using df1.merge(df2, on=['a','b']). But how do I change the value?


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images