I would like to color my rows based on my list of integer such that: if my integer is = [3, 10, 12]
the coloring of pandas style should be:
I was trying to do what How to highlight both a row and a column at once in pandas did. but didnt get what i want, snippets of my code:
color = ['red','green','blue','orange','yellow']
idx_list = [3, 10, 12]
def color_row(x):
bc = []
for i in x:
for j, idx in enumerate(idx_list):
c = 'background: '+color[j]
if x.name <= idx:
bc.append(c)
return bc
df.style.apply(color_row,axis=1)
and got this error:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
what did I miss?

