I have two pandas dataframes, say df1 and df2, of some size each but with different indexes and I would like to sum up the two dataframes element by element. I provide you an easy example to better understand the problem:
dic1 = {'a': [3, 1, 5, 2], 'b': [3, 1, 6, 3], 'c': [6, 7, 3, 0]}
dic2 = {'c': [7, 3, 5, 9], 'd': [9, 0, 2, 5], 'e': [4, 8, 3, 7]}
df1 = pd.DataFrame(dic1)
df2 = pd.DataFrame(dic2, index = [4, 5, 6, 7])
so df1 will be
a b c
0 3 3 6
1 1 1 7
2 5 6 3
3 2 3 0
and df2 will be
c d e
4 7 9 4
5 3 0 8
6 5 2 3
7 9 5 7
now if type
df1 + df2
what I get is
a b c d e0 NaN NaN NaN NaN NaN1 NaN NaN NaN NaN NaN2 NaN NaN NaN NaN NaN3 NaN NaN NaN NaN NaN4 NaN NaN NaN NaN NaN5 NaN NaN NaN NaN NaN6 NaN NaN NaN NaN NaN7 NaN NaN NaN NaN NaN
How can I make pandas understand that I want to sum up the two dataframe just element by element?