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.
Answers:
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)
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.
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)