This is a follow up question on applying background color to a dataframe based on condition
I am able to apply style based on the below:
f = lambda v: 'background-color: %s' % 'green' if v=='col' else ''
df = df.style.applymap(f, subset=['a'])
My challenge now is I want to do more filters on different cols. So If I try to apply this style.applymap
on df
again I get the error mentioned in title. Because it can be applied on DF and not styler object.
As a workaround I found to use df.data.style.applymap
to a styled object but then it is not retaining the previous style.
I have multiple filter conditions that may involve same columns for which style is already applied.
How can I apply multiple styles one after other ? Checked the documentation but didnt find anything