I have two data frames. I need to join them so that those index which have same name in both data frames are joined into one and their values summed. Those index which do not exist in the other data frame are created and their valued inserted. See example below.
dataFrame1:
index col1 col2 col3
A 3 0 4
C 4 1 2
D 3 5 6
G 3 0 0
dataFrame2
index col1 col2 col3
A 1 1 3
B 4 4 1
C 1 3 0
E 0 2 1
F 1 3 2
I need the following results:
index col1 col2 col3
A 4 1 7
B 4 4 1
C 5 4 2
D 3 5 6
E 0 2 1
F 1 3 2
G 3 0 0
how can I do this is pandas? Note: no value should be treated as zero unless it is zero or NaN in both data frames.