Hi,
I have below dataframe:
df:
threshold_ABK = 20
threshold_SGH = 19
threshold_JKL = 13
I want to make font color red if any value in particular row not_equal to threshold
I use below code, but when I open the excel it did not highlight anything
I have below dataframe:
df:
Name gender age rank code Mek m 29 2 23 ABK f 20 23 56 SGH f 23 19 12 JKL m 17 33 19threshold_mek = 12
threshold_ABK = 20
threshold_SGH = 19
threshold_JKL = 13
I want to make font color red if any value in particular row not_equal to threshold
I use below code, but when I open the excel it did not highlight anything
import pandas as pd df=pd.read_csv('input.csv') df.style.apply(lambda x:['background:red'' if x <threshold_mek else 'background:green' for x in df.loc[0]], axis=0) df.style.apply(lambda x:['background:red'' if x <threshold_ABK else 'background:red' for x in df.loc[1]], axis=0) df.style.apply(lambda x:['background:red'' if x <threshold_SGH else 'background:red' for x in df.loc[1]], axis=0) df.style.apply(lambda x:['background:red'' if x <threshold_JKL else 'background:red' for x in df.loc[1]], axis=0) df.styled.to_excel('styled.xlsx',engine='openpyxl',index=False)I want change the font color red if the any cell value > the row threshold from 2nd column to end in each row. Ican see the color in Jupiter but when write to excel and open excel not visible any color.