Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

dataframe color cells

import pandas as pd
import numpy as np

def highlight_max(s):
    is_max = s == s.max()
    return ['background-color: red' if v else '' for v in is_max]

df.style.apply(highlight_max)
 
PREVIOUS NEXT
Tagged: #dataframe #color #cells
ADD COMMENT
Topic
Name
8+7 =