Created
December 21, 2021 16:13
-
-
Save jjsantanna/628943fc3b0d82a2a39ad0d0a1b4e358 to your computer and use it in GitHub Desktop.
color display pandas
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
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