Highlight column key Pandas

Question:

I am looking to highlight only one specific row key, in this case "B" with pandas.

    1  2  3  4  5

A

B

C

I found different examples on how to highlight the row, but because the values in the row are color coded based on a conditional function and I need it to keep the color coding.

Asked By: Omar Silva

||

Answers:

Use Styler.applymap_index:

f = lambda v: "font-weight:bold;" if v=='B' else "font-weight:normal;"
f = lambda v: "font-weight:bold; color:red" if v=='B' else "font-weight:normal;"
df.style.applymap_index(f, axis=0)
Answered By: jezrael
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.