Consider the simple example below
df = pd.DataFrame({'text' : ['hello world'],
'var1' : [0.1],
'var2' : [0.2]})
#this highlights the highest number in red
def highlight_max(s, props = ''):
return np.where(s == np.nanmax(s.values), props, '')
#this turns the numbers into percentages
df.style.format({'var1' : '{:,.2%}'.format,
'var2' : '{:,.2%}'.format})
I am trying to automatically highlight the highest number (by rows) in red AND format any number into percentage. I have the two pieces separately but I do not know how to do this in just one .style call. Any ideas?
Thanks!
