This is an extension of my previous question enter link description here
I have two dataframes df1 and df2 of different lengths and two columns as key columns. I would like to perform multiple operations on these dataframes as follows:
- Replacing only the blanks (NAs) cells in df1 with corresponding values from df2 based on the key columns
- for each key columns pair, the cells from both the dataframes where values are contradicting should be reported in a new dataframe
df1
id_col1 id_col2 name age sex
---------------------------------------
101 1M 21
101 3M 21 M
102 1M Mark 25
df2
id_col1 id_col2 name age sex
-------------------------------------------
101 1M Steve M
101 2M M
101 3M Steve 25
102 1M Ria 25 M
102 2M Anie 22 F
After performing operation 1, i.e. replacing NA's in df1 with the corresponding values from df2, I should get the following:
result_1
id_col1 id_col2 name age sex
-------------------------------------------
101 1M Steve 21 M
101 3M Steve 25 M
102 1M Mark 25 M
After performing operation 2, i.e. conflicting cells in df1 and df2 for the same key columns, I should get the following:
result_2
id_col1 id_col2 name age sex
-------------------------------------------
101 3M 21
101 3M 25
102 1M Mark
102 1M Ria
Can anyone help in solving these?


