I am trying to color the text or cells of data frame based on the condition. This is the code I have. It works:
def Highlight_Majors(val):
color = 'blue' if val == "Austria" else 'black'
return 'color: %s' % color
s = df.style.applymap(Highlight_Majors)
s
The string "Austria" now appears highlighted in the dataframe. What if I have more than one countries I need to highlight?
This does not work:
def Highlight_Majors(val):
color = 'blue' if val == "Austria"|"Belgium" else 'black'
return 'color: %s' % color
What is the right way to do it?