title: Checking data-frame entries for duplicate records
body: <p>I have a data-frame <code>df</code> that I need to validate.  The <code>df</code> has several thousand records but looks something like:</p>
  
  <pre><code>   id         score  status
      1   0.204728295 current
      2   0.811946622 current
      3   0.255717294 current
      4   0.283495765 loan in
      4   0.355463338 loan out
      5   0.090287194 current
      6   0.195224702 current
      7   0.743183619 transfer in
      7   0.6677402   transfer out
      8   0.685349828 current
      9   0.664626162 current
      9   0.389797469 transfer in
      10  0.359471869 current
  </code></pre>
  
  <p>The validation is that there can only be a duplicate id in the df when:</p>
  
  <ul>
  <li>One of the duplicate status entries is 'transfer in' and the other entry with the same id had a status equal to 'transfer out' or</li>
  <li>one of the duplicate status entries is 'loan in' and the other entry with the same id had a status equal to 'loan out'</li>
  </ul>
  
  <p>Any instances where the above does not hold would need to be captured for correction.</p>
  
  <p>In the example id = 4 has a duplicate entry but the entries are valid as the status are 'loan in' and 'loan out'.  The same for id= 7 where the status's are 'transfer in' and 'transfer out'.  However id = 9 is invalid as the status's are 'current' and 'transfer in'</p>
  
  <p>The output from the exercise would just be the records that fil validation.  In this case it would be:</p>
  
  <pre><code>   id         score  status
      9   0.664626162 current
      9   0.389797469 transfer in
  </code></pre>
  
  <p>I have figured out that I can look for duplicate records by using the following:</p>
  
  <pre><code>countdf = df.groupby('id').count()
  result = df.loc[df['id'].isin(countdf[countdf['id'] &gt; 1].index)]
  </code></pre>
  
  <p>but cannot figure out how then to check the duplicates ids against if they are mapped up to valid statuses.</p>