title: Filter duplicate rows of a pandas DataFrame
body: <p>I'm trying to filter the rows of a pandas DataFrame based on some conditions and I'm having difficulties with it. The DataFrame is like so: </p>
  
  <pre><code>import pandas as pd
  import numpy as np
  
  df = pd.DataFrame({'cus_id': [1111, 2222, 2222, 3333, 4444, 4444, 4444, 5555, 5555], 
                    'cus_group' : [1, 1, 0, 0, 1, 1, 0, 0, 0]})
  
  print(df)
  
     cus_id  cus_group
  0    1111          1
  1    2222          1
  2    2222          0
  3    3333          0
  4    4444          1
  5    4444          1
  6    4444          0
  7    5555          0
  8    5555          0
  </code></pre>
  
  <p>The selection I would like to apply is the following: </p>
  
  <p>For all <strong>cus_id</strong> that appear more than once (i.e. for all duplicates <strong>cus_id</strong>), keep only the ones where <strong>cus_group</strong> is equal to 1. Caution: If a <strong>cus_id</strong> appears more than once but it only belongs to group 0, we keep all instances of this customer.</p>
  
  <p>Visually, the resulting DataFrame I want is like so:</p>
  
  <pre><code>   cus_id  cus_group
  0    1111          1
  1    2222          1
  2    3333          0
  3    4444          1
  4    4444          1
  5    5555          0
  6    5555          0
  </code></pre>
  
  <p>As you can see for <strong>cus_id</strong> = 5555, even though it does appear twice, we keep both records since it only belongs to group 0. I have tried a few things using the duplicated() method but with no success. Any additional help is would be appreciated. </p>
  
  <hr>
  
  <p><strong>EDIT:</strong> The solution provided by <strong>jezrael</strong> works perfectly for the example above. I have noticed that in the real DataFrame I'm using there are cases where customers are linked to <code>NaN</code> group. For example:</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  
  df = pd.DataFrame({'cus_id': [1111, 2222, 2222, 3333, 4444, 4444, 4444, 5555, 5555, 6666, 7777, 7777, ], 
                    'cus_group' : [1, 1, 0, 0, 1, 1, 0, 0, 0, np.nan, np.nan, np.nan]})
  
  print(df)
  
      cus_id  cus_group
  0     1111        1.0
  1     2222        1.0
  2     2222        0.0
  3     3333        0.0
  4     4444        1.0
  5     4444        1.0
  6     4444        0.0
  7     5555        0.0
  8     5555        0.0
  9     6666        NaN
  10    7777        NaN
  11    7777        NaN
  </code></pre>
  
  <p>Using the solution of <strong>jezrael</strong> those customers are dropped. Is there a quick fix to keep <strong>ALL</strong> (duplicates included) such cases in the final DataFrame? Visually (after filtering):</p>
  
  <pre><code>    cus_id  cus_group
  0     1111        1.0
  1     2222        1.0
  2     3333        0.0
  3     4444        1.0
  4     4444        1.0
  5     5555        0.0
  6     5555        0.0
  7     6666        NaN
  8     7777        NaN
  9     7777        NaN
  </code></pre>