given two data frames:
a=pd.DataFrame({'col1':[1],'col2':[4]},index=[0])
b=pd.DataFrame({'col3':[7],'col4':[8]},index=[1])
how do I get dataframe c:
c=pd.DataFrame({'col1':[1],'col2':[4],'col3':[7],'col4':[8]},index=[1])
Try this .i believe you can use the append
c = a.append(b,True)
Because you have a mismatch on your indices you have to overwrite them:
In [66]:
a.index=b.index
pd.concat([a,b], axis=1)
Out[66]:
col1 col2 col3 col4
1 1 4 7 8
If you didn't do this then you get an additional row:
In [71]:
pd.concat([a,b], axis=1)
Out[71]:
col1 col2 col3 col4
0 1 4 NaN NaN
1 NaN NaN 7 8