Skip to content

Instantly share code, notes, and snippets.

@ttor
Created January 12, 2022 17:06
Show Gist options
  • Save ttor/273070c2d42cbc6ced2ddd723babb049 to your computer and use it in GitHub Desktop.
Save ttor/273070c2d42cbc6ced2ddd723babb049 to your computer and use it in GitHub Desktop.
Compare two pandas dataframes for equality, pandas_dataframes_are_equal
def pandas_dataframes_are_equal(df1, df2):
return list(sorted(df1.columns)) == list(sorted(df2.columns)) and \
len(df1.merge(df2, how="outer", indicator=True).query("_merge!='both'"))==0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment