title: pandas how to drop duplicated rows based on conditions
body: <p>I have a df ,you can have by this code:</p>
  <pre><code>import numpy as np
  import pandas as pd
  from io import StringIO
  dfs = &quot;&quot;&quot;
      contract  RB RateCompany gs  IssueDate  ValIssueDate   ToDate1  FromDate1
  84  GA16      77           T  G   19940701    19480101.0  197702.0   190001.0
  85  GA16      77           T  G   19940701    19980101.0  999999.0   197703.0
  
  &quot;&quot;&quot;
  df = pd.read_csv(StringIO(dfs.strip()), sep='\s+', 
                    dtype={&quot;RB&quot;: int}
                    )
  df
  </code></pre>
  <p>Out put:</p>
  <pre><code>contract    RB  RateCompany gs  IssueDate   ValIssueDate    ToDate1    FromDate1
  84  GA16    77  T           G   19940701    19480101.0      197702.0    190001.0
  85  GA16    77  T           G   19940701    19980101.0      999999.0    197703.0
  </code></pre>
  <p>For this df, a set of contract with RB ,is unique，it means only 1 row should be left,and the condition is:</p>
  <pre><code>FromDate1&lt;=df.IssueDate&lt;=ToDate1
  </code></pre>
  <p>So I tired:</p>
  <pre><code>df = df[((df.duplicated(subset=[&quot;contract&quot;, &quot;RB&quot;], keep=False)) &amp;
                   (df['IssueDate'] &lt;= df['ToDate1']) &amp;
                   (df['IssueDate'] &gt;= df['FromDate1']))]
  </code></pre>
  <p>But the output is blank:</p>
  <pre><code>contract    RB  RateCompany gs  IssueDate   ValIssueDate    ToDate1 FromDate1
  </code></pre>
  <p>The expected  output should be:</p>
  <pre><code>contract    RB  RateCompany gs  IssueDate   ValIssueDate    ToDate1    FromDate1
  
  85  GA16    77  T           G   19940701    19980101.0      999999.0    197703.0
  </code></pre>
  <p>any friend can help?</p>