I have two dataframes like these:
df1 = pd.DataFrame({'A': [1,0,3], 'B':[0,0,1], 'C':[0,2,2]}, index =['a','b','c'])
df2 = pd.DataFrame({'A': [0,0], 'B':[2,1]}, index =['a','c'])
df1 and df2:
| A | B | C | | A | B |
---|---|---|---| ---|---|---|
a | 1 | 0 | 0 | a | 0 | 2 |
b | 0 | 0 | 2 | c | 0 | 1 |
c | 3 | 1 | 2 |
And the expected result is:
| A | B | C |
---|---|---|---|
a | 1 | 2 | 0 |
b | 0 | 0 | 2 |
c | 3 | 2 | 2 |
I'm having problems with this because there may be missing columns/rows in any of the dataframes (df1 may not have all columns and rows df2 has)