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)