Skip to content

Instantly share code, notes, and snippets.

@timotta
Created July 29, 2021 12:28
Show Gist options
  • Save timotta/11b2c1e2c1a8c694cfe8c80d90ba7594 to your computer and use it in GitHub Desktop.
Save timotta/11b2c1e2c1a8c694cfe8c80d90ba7594 to your computer and use it in GitHub Desktop.
Colour the best cell from column in pandas DataFrame
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