Q:

Pandas Combining data in two excel

I have two excel
Excel 1
files   language    blank   comment code
15       C++            66  35      354
1       C/C++ Header    3   7        4

Excel 2
files   language    blank   comment code
16       C++           33   35      354
1       C/C++ Header    3   7        4
1       Python          1   1        1

Trying to get combined excel
files   language    blank   comment code
31       C++           99   70      708
2       C/C++ Header    6   14       8
1       Python          1   1        1

Any tips in pandas

A:

Use concat with aggregate sum by groupby:
df = pd.concat([df1, df2]).groupby('language', as_index=False).sum()
print (df)
       language  files  blank  comment  code
0           C++     31     99       70   708
1  C/C++ Header      2      6       14     8
2        Python      1      1        1     1

If order of columns is important add reindex:
df=pd.concat([df1, df2]).groupby('language',as_index=False).sum().reindex(columns=df1.columns)
print (df)
   files      language  blank  comment  code
0     31           C++     99       70   708
1      2  C/C++ Header      6       14     8
2      1        Python      1        1     1

