keep row highlighting after writing pandas dataframe to excel

47 views Asked by At

i have the following code where in I am trying to apply some highlighting to my dataframe then writing it to an excel sheet. However i am unable to see the highlighting in the excel sheet.

df_merged_styled_data = df_merged_data.style.apply(lambda x: ['background: green' if x['Snap TV (Orc)'] == x['Snap TV (VC)'] else 'background: red' for i in x], axis=1)

with pd.ExcelWriter('US_HK_PNL_data.xlsx', mode='a', if_sheet_exists='replace') as writer:
    df_merged_styled_data.to_excel(writer, sheet_name='Data Discrepancies', index=False)

Can anyone help me with this?

0

There are 0 answers