In my code I am using df.style.applymap() to render HTML onto my intranet Webpage. I have the following Code which is working Well for me, (2 Columns are passed on to my function highlight_vals).
def highlight_vals(val, color='green', color1='red'):
if val > 0.8:
return 'background-color: %s' % color
elif val < -0.9:
return 'background-color: %s' % color1
else:
return ''
Now, I want to make a similar function (or ever use the current highlight_vals) in order to achieve Comparative Highlighting with the condition on the lines of:
if ValinColumn1 > 0.25 * ValinColumn2: # (For same Row/Record)
return 'background-color: %s' % color #Yellow/Highlights.
I am using the above function in my views.py:
httresp += df.style.applymap(highlight_vals,subset=[col1,col2])