Created
January 12, 2022 17:06
-
-
Save ttor/273070c2d42cbc6ced2ddd723babb049 to your computer and use it in GitHub Desktop.
Compare two pandas dataframes for equality, pandas_dataframes_are_equal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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