I would like to test if the values of a column are bigger than another specific value of the same data frame. If a value is bigger, I want to highlight this specific cell.
I tried this:
import pandas as pd
b = pd.DataFrame([[5,7,3],[2,3,4],[8,4,7]])
for i in range(0, len(b)):
for j in range(0, len(b.columns)):
if b.iloc[i][j] > b.iloc[2][j]:
b.style.applymap(lambda x: 'background-color : blue' if b.iloc[i][j] > b.iloc[2][j] else '')
b
So in this example I want to check if 5 or 7 is bigger than 3 (column 1), 2 or 3 bigger than 4 (column 2) and 8 or 4 is bigger than 7.
It doesn't color anything... I hope someone can help me. Thx in advance.