Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Solution from these threads

Comparing two pandas dataframes for differencesComparing two pandas dataframes for differences

Pandas DataFrames with NaNs equality comparisonPandas DataFrames with NaNs equality comparison

def df_equal(self): try: assert_frame_equal(csvdata, csvdata_old) return True except: return False 

For a dictionary of dataframes:

def df_equal(df1, df2): try: assert_frame_equal(df1, df2) return True except: return False def __eq__(self, other): if self.df.keys() != other.keys(): return False for k in self.df.keys(): if not df_equal(self.df[k], other[k]): return False return True 

Solution from these threads

Comparing two pandas dataframes for differences

Pandas DataFrames with NaNs equality comparison

def df_equal(self): try: assert_frame_equal(csvdata, csvdata_old) return True except: return False 

For a dictionary of dataframes:

def df_equal(df1, df2): try: assert_frame_equal(df1, df2) return True except: return False def __eq__(self, other): if self.df.keys() != other.keys(): return False for k in self.df.keys(): if not df_equal(self.df[k], other[k]): return False return True 

Solution from these threads

Comparing two pandas dataframes for differences

Pandas DataFrames with NaNs equality comparison

def df_equal(self): try: assert_frame_equal(csvdata, csvdata_old) return True except: return False 

For a dictionary of dataframes:

def df_equal(df1, df2): try: assert_frame_equal(df1, df2) return True except: return False def __eq__(self, other): if self.df.keys() != other.keys(): return False for k in self.df.keys(): if not df_equal(self.df[k], other[k]): return False return True 
adding additional example code in response to a comment
Source Link
ate50eggs
  • 454
  • 3
  • 14

Solution from these threads

Comparing two pandas dataframes for differences

Pandas DataFrames with NaNs equality comparison

def __eq__df_equal(self): try: assert_frame_equal(csvdata, other_dfcsvdata_old) return True except:   return False 

For a dictionary of dataframes:

def df_equal(df1, df2): try: assert_frame_equal(self.dfdf1, other_dfdf2) return True except: return False def __eq__(self, other): if self.df.keys() != other.keys():  return False for k in self.df.keys(): if not df_equal(self.df[k], other[k]): return NotImplementedFalse return True 

Solution from these threads

Comparing two pandas dataframes for differences

Pandas DataFrames with NaNs equality comparison

def __eq__(self, other_df): try: assert_frame_equal(self.df, other_df) return True except: return False return NotImplemented 

Solution from these threads

Comparing two pandas dataframes for differences

Pandas DataFrames with NaNs equality comparison

def df_equal(self): try: assert_frame_equal(csvdata, csvdata_old) return True except:   return False 

For a dictionary of dataframes:

def df_equal(df1, df2): try: assert_frame_equal(df1, df2) return True except: return False def __eq__(self, other): if self.df.keys() != other.keys():  return False for k in self.df.keys(): if not df_equal(self.df[k], other[k]): return False return True 
Edited to match the format of the question better
Source Link
ate50eggs
  • 454
  • 3
  • 14

Solution from these threads

Comparing two pandas dataframes for differences

Pandas DataFrames with NaNs equality comparison

def df_equal__eq__(self, other_df): try: assert_frame_equal(csvdataself.df, csvdata_oldother_df) return True except: return False return NotImplemented 

Solution from these threads

Comparing two pandas dataframes for differences

Pandas DataFrames with NaNs equality comparison

def df_equal(self): try: assert_frame_equal(csvdata, csvdata_old) return True except: return False 

Solution from these threads

Comparing two pandas dataframes for differences

Pandas DataFrames with NaNs equality comparison

def __eq__(self, other_df): try: assert_frame_equal(self.df, other_df) return True except: return False return NotImplemented 
Source Link
ate50eggs
  • 454
  • 3
  • 14
Loading