I have the following dataframe:
df=pd.DataFrame({'c1':['a','b','c'],
'c2':['aa', 'bb','cc'] })
And I have the following function to color cells:
def color_cell(cell, c):
if cell in c:
return "background-color: yellow"
else:
return ""
I want to use this function to color different columns of the dataframe.
For each column there is different c.
I try this:
cols=['c1', 'c2']
c1=['a']
c2=['aa', 'bb']
c= [c1, c2]
for i in range(0, 2):
html = (df.style
.applymap(color_cell,
c=c[i],
subset = cols[i])
.render()
)
(HTML(html))
Obviously, this doesn't work because only the result from the last iteration is returned.
What should I do to get all the columns colored?

