I have applied pandas on an excel file and below is the dataframe :
Name Count
0 Name 1 75
1 Name 2 55
2 Name 3 50
3 Name 4 47
4 Name 5 43
5 Name 6 42
6 Name 7 35
7 Name 8 34
8 Name 9 32
9 Name 10 16
10 Name 11 6
11 Name 12 3
12 Name 13 1
13 Name 14 1
14 Total 440
I have to apply conditional formatting on above data frame and convert in to html.
I followed style "http://pandas.pydata.org/pandas-docs/stable/style.html#Building-Styles" for this and did below :
def change_colour(val):
return ['background-color: red' if x < 40 else 'background-color: green' for x in val]
name_column_html_1 = final_name_df.style.apply(change_colour, axis=1, subset=['Count'])
print(name_column_html_1.render())
This is the output I am getting from above code
How can i get output like below ?