I have df1 (key_col, cola, colb, colc) and df2(key_col, colz) I want to do the SQL equivalent of:
UPDATE df1
SET df1.colc = df2.colz
WHERE df1.key = df2.key
I've tried various incarnations of merge and join without success. Not looking for loops but rather using Pandas
df1: key_col cola colb colc
50 'foo' 'bar' 'foo'
49 'foo' 'bar' 'bla'
23 'bar' 'foo' 'bla'
df2: key_col colz
23 'something'
50 'something else'
Note, the key col is not a pandas index rather a normal column
Resulting df1 desired:
df1: key_col cola colb colc
50 'foo' 'bar' 'something else'
49 'foo' 'bar' 'bla'
23 'bar' 'foo' 'something'
EDIT:
Have added row key_col = 49 to make clear that a straight copy over of colc c will not work as it will overwrite existing values.