0

I have two dataframes with n number of common columns. There are 48 columns in the first and 56 columns in the other one. I'm trying to concat these columns vertically using pd.concat and I'm always getting the following error Reindexing only valid with uniquely valued Index objects.

df1

Column 1 Column 2 Column3
a b c

df2

Column 1 Column 3 Column 2 Column 5 Column 6 Column 7
a b c a Nan c

I want to concat this vertically. But I get the following error Reindexing only valid with uniquely valued Index objects.

Merged_Data = pd.concat([Merged_Data,df] , join = "outer", ignore_index = True).reset_index(drop = True)

It's a huge dataframe and can't share it due to security reasons. I believe the problem lies in the column indexing but I have tried a lot of things

  • Can you post the code, that's returning the error you mentioned? – Grzegorz Skibinski Mar 18 '21 at 16:19
  • 3
    There are [many ways to use `concat`](https://stackoverflow.com/q/49620538/2336654). I would like to see the dataframes with the index intact and the actual `concat` statement you are using. – piRSquared Mar 18 '21 at 16:22

1 Answers1

0

What if you just use

pd.concat([df1, df2])

without the index or reset_index parts?

Gilian
  • 38
  • 4