Skip to content
Advertisement

Python Pandas style highlight specific cells for each column with different condition

I’m trying to highlight specific cells for each column with different condition which their value matches the condition for each row.

Below image is what I want to achieve: The table I attempt to achieve

I searched google and stackoverflow but none of these can meet my requirement. Can anyone who’s familiar with Pandas Style could assist?

Below are the codes I tried and failed:

Ex1

JavaScript

Ex2

JavaScript

Ex3

JavaScript

Advertisement

Answer

If there is same number of conditions like some number of columns use:

JavaScript

If there is a lot of columns and need processing only some of them:

JavaScript

EDIT:

If need specified all masks but in last step filter only some columns use:

JavaScript

Or remove masks which not necessary:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement