Q:

Addition of 2 dataframes column to column by unique column in pandas

I have 2 dataframes 
df1

a b c 
1 2 3
2 4 5
3 6 7 

and 
df2
a b c
1 3 4
3 1 8

I want output to be
df3 
a b c
1 5 7
2 4 5
3 7 15

I tried df1.add(df2,axis='c') but not getting exact output.
referring this link http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.add.html

A:

You need set_index by column a in both df with add and parameter fill_value=0.
Last if necessary convert values to int and reset_index:
df = df1.set_index('a').add(df2.set_index('a'),fill_value=0).astype(int).reset_index()
print (df)
   a  b   c
0  1  5   7
1  2  4   5
2  3  7  15

For removing not common rows omit fill_value and add dropna if no NaN in both DataFrames
df = df1.set_index('a').add(df2.set_index('a')).dropna().astype(int).reset_index()
print (df)
   a  b   c
0  1  5   7
1  3  7  15

