give cell format to condition pandas dataframe

Solutions on MaxInterview for give cell format to condition pandas dataframe by the best coders in the world

showing results for - "give cell format to condition pandas dataframe"
Leon
14 Sep 2017
1import pandas as pd
2df = pd.DataFrame([[2,3,1], [3,2,2], [2,4,4]], columns=list("ABC"))
3
4df.style.apply(lambda x: ["background: red" if v > x.iloc[0] else "" for v in x], axis = 1)
5