I am trying to highlight all the values that are greater than 1 in a column. I also want to highlight the column name that contains this value. I achieve the highlighting the values using below code, but how to highlight the index or axis (column name).
import pandas as pd import numpy as np
data = pd.DataFrame(np.random.randn(5, 3), columns=list('ABC'))
#print (data)
def highlight_cols(s):
color = 'yellow' if s > 1 else 'white'
#color = 'white'
return 'background-color: %s' % color
data.style.applymap(highlight_cols)
Aucun commentaire:
Enregistrer un commentaire