I have the following dataframe:
df = pd.DataFrame({"A":["foo", "foo", "foo", "bar"],
"B":["A","A","B","A"],
"C":[0,3,1,1]})
How can I change the cell color of columns A and B, grouped by its values. I mean, this would be the desirable output:
Maybe something like:
df.groupby(by=['A', 'B']).style.change_background()
As the real dataframe has hundreds of rows, I'd be interestested in assigning the colors automatically.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…