Cross check two years data
Method#1
I compared cell-to-cell using df1.eq, and although it showed the difference, it failed when the data was not sorted also too many empty cell in the excel make it ineffective for my sheet
colormat = df1.equal(df2).replace({False: ‘background-color:
lightcoral’,
True: ‘background-color: wheat’}) df2.style.apply(lambda _: colormat, axis=None).to_excel(“Member.xlsx”,
engine=”openpyxl”)
Method#2
By combining two data frames with a key column and creating two columns, I was able to obtain the desired results.
Method#2 is applicable to all tables with Key columns. There are multiple table structures for each dataframe (sheet), including two columned tables, five columned tables, and many more. Almost all of them have key columns to compare, but most do not. For columns that are not key, df.eq is effective.
Ask?
How to compare sheets with one or more table with and without key column ?