I have a dataframe each cell in one of the columns contains a list in the format [2,19,25,39,49]
. I would like to color individual values in each list that are contained in a list common = [7,9,16,18,19,20,21,25,33,35,38,40,49]
, so in the example 19,25 and 49 should be colored differently or that is what I would like to achieve.
I have tried using:
def color_common(x):
if x in common:
color='green'
else:
color='black'
I get the response, "The truth value of a Series is ambiguous". if I use x.any(), I get "Result has shape: (6,) Expected shape: (5, 6)" I don't understand the expected shape comment nor the ambiguous truth and where/how to apply any() or all(). Is it possibile to color components of a list.I manage to color whole cells or the contents of a cell quite easily. I have not styled a Panda dataframe before hence possibily the 'dumbness of my question