There are questions similar to this on SO but I am yet to see one exactly like this - replacing with multiple columns as keys. I have two dataframes. Example below:
df1 = pd.DataFrame([["X",Monday,1,0],
["Y",Tuesday,1,0],
["Z",Wednesday,0,0],
["Y",Thursday,0,0]],columns=["First","Second","Third", "Fourth"])
and
df2 = pd.DataFrame([["X",Monday,3,0],
["Y",Tuesday,7,1],
["Z",Wednesday,6,2]],columns=["First","Second","Third", "Fourth"])
What I want is for df2 to replace every 'Third' and 'Fourth' columns in df1 when 'First' and 'Second' columns match. So result will be
df3 = pd.DataFrame([["X",Monday,3,0],
["Y",Tuesday,7,1],
["Z",Wednesday,6,2],
["Y",Thursday,0,0]],columns=["First","Second","Third", "Fourth"])
I have tried the update and is.in but they work with index and one column only as far as I know.
Can anyone help please?