title: Pandas style applymap highlight duplicates with lambda function
body: <p>I have a Pandas dataframe and am working in a Jupyter notebook. I want to highlight rows in which column pairs are duplicated. Here is an example:</p>
  
  <pre><code>colA = list(range(1,6))
  colB = ['aa', 'bb', 'aa', 'cc', 'aa']
  colC = [14,3,14,9,12]
  colD = [108, 2001, 152, 696, 696]
  df = pd.DataFrame(list(zip(colA, colB, colC, colD)), columns =['colA', 'colB', 'colC', 'colD']) 
  display(df)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/L4mze.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L4mze.png" alt="enter image description here"></a></p>
  
  <p>I want to highlight these rows, because the values in colB and colC are duplicates:</p>
  
  <p><a href="https://i.stack.imgur.com/NHceY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NHceY.png" alt="enter image description here"></a></p>
  
  <p>I am trying this lambda function, but it throws an error (and it's only for one column):</p>
  
  <pre><code>df.style.applymap(lambda x: 'background-color : yellow' if x[colB].duplicated(keep=False) else '')
  TypeError: ("'int' object is not subscriptable", 'occurred at index colA')
  </code></pre>
  
  <p>Thanks for any help</p>