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
  • 6,460
  • 1
  • 20
  • 39

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
  • 729,927
  • 78
  • 1,141
  • 1,090
1

You should try the merge method.

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

pissall
  • 6,460
  • 1
  • 20
  • 39
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
  • 303
  • 2
  • 11