daily pastebin goal
71%
SHARE
TWEET

Untitled

a guest Oct 12th, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # creates an empty list to append to
  2. differences = []
  3. # for all the IDs in the dataframe that should not change check if this record is the same in the database
  4. # must use reset_index() so the equals() will work as I expect it to
  5. # if it is not the same, append to a list which has the Aspn ID that is failing, along with the columns that changed
  6. for unique_id in new_df['ID'].tolist():
  7.     if new_df.loc[new_df['ID'] == unique_id].reset_index(drop=True).equals(sql_df.loc[sql_df['ID'] == unique_id].reset_index(drop=True)) is False:
  8.         bad_columns = []
  9.         for column in new_df.columns.tolist():
  10.             if new_df.loc[new_df['ID'] == unique_id][column].reset_index(drop=True).equals(sql_df.loc[sql_df['ID'] == unique_id][column].reset_index(drop=True)) is False:
  11.                 bad_columns.append(column)                            
  12.         differences.append([unique_id, bad_columns])
RAW Paste Data
Top