Equals with row permutation using Pandas

Viewed 209

I want to check if two data frames have the same rows. I've tried:

df1.equals(df2)

But it returns False, because rows are not in the same order. Is there any function which check equals, but with row permutation? Thank You very much for any help.

1 Answers

In pandas the index is important , if the index different even all value same in the rows, we should still treat it as different , however we can do merge

df1.merge(df2, indicator=True, how='outer')['_merge'].eq('both').all()
Related