title: How to change background cell color according with a given key in pandas?
body: <p>I have the following dataframe:</p>
  
  <pre><code>df = pd.DataFrame({"A":["foo", "foo", "foo", "bar"],  
                     "B":["A","A","B","A"], 
                     "C":[0,3,1,1]})
  </code></pre>
  
  <p>How can I change the cell color of columns A and B, grouped by its values. I mean, this would be the desirable output:</p>
  
  <p><a href="https://i.stack.imgur.com/uNE9r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uNE9r.png" alt="enter image description here"></a></p>
  
  <p>Maybe something like:</p>
  
  <pre><code>df.groupby(by=['A', 'B']).style.change_background()
  </code></pre>
  
  <p>As the real dataframe has hundreds of rows, I'd be interestested in assigning the colors automatically.  </p>