Skip to content

Instantly share code, notes, and snippets.

@jjsantanna
Created December 21, 2021 16:13
Show Gist options
  • Save jjsantanna/628943fc3b0d82a2a39ad0d0a1b4e358 to your computer and use it in GitHub Desktop.
Save jjsantanna/628943fc3b0d82a2a39ad0d0a1b4e358 to your computer and use it in GitHub Desktop.
color display pandas
df_test = df[df['score']>80]
def color_row(row):
value = row.loc["score"] #indicate which column this is based on
if value < 130:
color = 'pink'
elif value >130:
color = 'lightgreen'
else:
color = 'black'
return ['background-color: %s' % color for r in row]
df_test.style.apply(color_row, axis=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment