I have the foll. 2 pandas dataframes:
df1 = pandas.DataFrame(data = {'col1' : [1, 2, 3, 4, 5], 'col2' : [10, 11, 12, 13, 14], 'col3' : [0,2,0,-1,0]})
df2 = pandas.DataFrame(data = {'col1' : [1, 2, 3], 'col2' : [10, 11, 12], 'col6' : [20, 31, 12]})
How do I change the value in col3
in df1 to 0 if both col1
and col2
have same value in df1 and df2. The result for df1 should look like this:
col1 col2 col3
0 1 10 0
1 2 11 0
2 3 12 0
3 4 13 -1
4 5 14 0