Not able to outer join two dataframe

Viewed 70

I am using this code to merge two dataframe : pd.concat(df1, df2, on='a', how='outer')

I am getting the following error:-

TypeError: concat() got an unexpected keyword argument 'on'

3 Answers

I believe you want merge:

df = pd.merge(df1, df2, on='a', how='outer')

But also concat is possible - it return default outer join by index of both DataFrames, so added [] and DataFrame.set_index:

df = pd.concat([df1.set_index('a'), df2.set_index('a')], axis=1)

You should try the merge method.

pd.merge(df1, df2, how='outer', on='a')

Related