Home > OS >  I got error while trying to put background color in dataframe column
I got error while trying to put background color in dataframe column

Time:01-21

Here is the dataframe which i have used :

enter image description here

i have tried following code :

def color_red_or_green(val):
    color = 'green' if val >= 70 else 'orange' if val < 70 & val >= 40 else "red"
    return 'color: %s' % color
week2_Percentage.style.apply(color_red_or_green, subset = ['availability'])

Which maps condition of the column name availbility for background color but got following error :

enter image description here

CodePudding user response:

The apply function is performed "column-wise, row-wise, or table-wise" according to its enter image description here

  • Related