2

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'

pissall
  • 7,109
  • 2
  • 25
  • 45

3 Answers3

4

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)
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252
1

You should try the merge method.

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

pissall
  • 7,109
  • 2
  • 25
  • 45
0

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.concat.html#pandas.concat

Here's the documentation for concat. As you can see, there is no 'on' (or how) arg, so you just need to adjust your parameters accordingly.

c4llmeco4ch
  • 311
  • 2
  • 11