Created
July 29, 2021 12:28
-
-
Save timotta/11b2c1e2c1a8c694cfe8c80d90ba7594 to your computer and use it in GitHub Desktop.
Colour the best cell from column in pandas DataFrame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def color_the_best(x): | |
styles = [] | |
bigger = max(x) | |
for i in x: | |
if i == bigger: | |
styles.append('background-color: lightgreen') | |
else: | |
styles.append('') | |
return styles | |
df.style.apply(color_the_best, axis=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment