Reputation: 43
I have two dataframes with unique indexes:
import pandas as pd
df1 = pd.DataFrame({'a':[4,6,3,0], 'b':[5,6,3,9], 'c':[4,3,6,6]}, index=['a1','a2','a3','a4'])
df2 = pd.DataFrame({'a':[10,5,13,10], 'b':[52,61,33,19], 'c':[14,23,36,16]}, index=['b1','b2','b3','b4'])
However, when I concat the two dataframes as follows:
df = pd.concat([df1,df2])
I get the following error:
pandas.errors.InvalidIndexError: Reindexing only valid with uniquely valued Index objects
I am not sure what is going on here. Can someone point me to what I am doing wrong.
Upvotes: 0
Views: 1121
Reputation: 43
So for purposes of demo'ing what I was doing I posed the above to represent my data (proprietary data) and the challenge I was facing. It turned out that the sample above works so it wasn't a good representation. The actual problem has over 100 dataframes.
Anyway I figured the issue was due to some dataframes having empty columns. Once I dropped the empty columns in those dataframes, everything worked fine.
Thanks!
Upvotes: 1