title: Return Pandas dataframe rows where more than N columns have the same value
body: <p>Let's say I have the following dataframe <code>df</code>. How can I take in a value N and return only rows where N columns have the same value? For example if N=3, it would return rows 0,2,3,4. If N=4, then only row 3. </p>
  
  <pre><code>      'A'   'B'   'C'  'D'   'E'
  
  0      1     1     1    3     5
  1      5     4     2    1     2
  2      3     4     3    2     3
  3      5     5     5    4     5
  4      1     2     1    2     1
  </code></pre>
  
  <p>I've found answers like <a href="https://stackoverflow.com/questions/21231478/get-rows-that-have-the-same-value-across-its-columns-in-pandas">this one</a> that are for cases when all values are the same, but can't think of a clean way to adapt it for when it wants an arbitrary number of columns to be the same.</p>