I have a excel which I am reading into DataFrame, comparing the columns and highlight one column and writing to excel. Below is the code and it's not working. I am not seeing cell highlighted. Not sure what I am doing wrong as I learning python.
file = Path(path to excel)
frm_df = pd.read_excel(file)
def highlight(row):
if row['AMOUNT A'] != row['AMOUNT B'] and row['AMOUNT C'] != row['AMOUNT D']:
color = 'red'
background = ['background-color: {}'.format(color) for _ in row]
return background
frm_df.style.apply(highlight)
writer = pd.ExcelWriter(path to excel)
frm_df.to_excel(writer, 'data')
writer.save()
DataFrame before applying highlight:
AMOUNT A AMOUNT B AMOUNT C AMOUNT D
1400 1400
3000 3000
1500 2500 2400 2300
3500 3500
Below is how I want in Excel:

