Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

How to colour a specific cell in pandas dataframe

def color_negative_red(val):
    """
    Takes a scalar and returns a string with
    the css property `'color: red'` for negative
    strings, black otherwise.
    """
    color = 'red' if val < 0 else 'black'
    return 'color: %s' % color
Source by pandas.pydata.org #
 
PREVIOUS NEXT
Tagged: #How #colour #specific #cell #pandas #dataframe
ADD COMMENT
Topic
Name
5+3 =