Created
October 30, 2019 12:11
-
-
Save philMarius/d254ebdc53c894a09153fc36cd63ab7d to your computer and use it in GitHub Desktop.
Comparing values between two different dataframe
This file contains 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 equal_dataframes(self, a_df, b_df, columns): | |
"""Equality check between dataframe values, first selects relevant columns, then sorts, then compares values.""" | |
# NOTE fillna is used to eliminate NaNs as NaN != NaN | |
# https://stackoverflow.com/a/23666623/2126910 | |
return (a_df[columns].sort_values(list(columns)).fillna(0).values == | |
b_df[columns].sort_values(list(columns)).fillna(0).values).all() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment