title: Subsetting duplicate rows in Python
body: <p>I have a data frame that looks like:</p>
  
  <pre><code>Name    State    Gender    OtherVariables
  Sam     CO       M
  Sam     CO       F
  Sam     CO       M
  Jim     CO       M
  Jim     WY       M
  </code></pre>
  
  <p>The following code gives me all of the duplicate names: (Sam and Jim):</p>
  
  <pre><code>def list_duplicates(seq):
    seen = set()
    seen_add = seen.add
    seen_twice = set(x for x in seq if x in seen or seen_add(x))
    return list(seen_twice)
  
  dups = list_duplicates(df.name)
  </code></pre>
  
  <p>But what I want is:</p>
  
  <pre><code>Name    State    Gender
  Sam     CO       M
  </code></pre>
  
  <p>I only want those rows with the same Name, State and Gender. So Jim shouldn't be there. The "OtherVariables" are different for each row.</p>