Created
January 3, 2022 07:17
-
-
Save kshirsagarsiddharth/0e5bfe3e9d22ffc28f4a58f18019cd34 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
## Highliting losses in the dataframe | |
def color_negative_values(value): | |
""" | |
This function takes in values of dataframe | |
if particular value is negative it is colored as redwhich implies loss | |
if value is greater than one it implies higher profit | |
""" | |
if value < 0: | |
color = '#ff8a8a' | |
elif value > 1: | |
color = '#4fc277' | |
else: | |
color = 'black' | |
return f"color: {color}" | |
companies_returns.style.applymap(color_negative_values) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment