title: Pandas merge on exact match and date column with condition
body: <p>I want to use pd.merge to left join df1 to df2, using ID and Company as exact matches and match dates where df1['Date1'] is greater than df2['Date2']. The issue is I get duplicates because df2 has multiple matches.</p>
  
  <p>df1:</p>
  
  <pre><code>Company   Revenue     ID        Date1
   XX       1000.0    12345x    2020-02-11
   XX       6000.0    12345x    2020-01-02
   AA       5000.0    12346a    2019-12-20
   BB       100.0     22345x    2019-11-07
   FF       18000.0   32345x    2020-01-11    
  </code></pre>
  
  <p>df2:</p>
  
  <pre><code>Company   Clicks     ID         Date2
   XX       1         12345x    2019-07-11
   XX       0         12345x    2020-01-10
   AA       0         12346a    2019-12-27
   BB       1         22345x    2019-11-07
   FF       1         32345x    2019-03-11
   FF       0         32345x    2019-08-28
  </code></pre>
  
  <p>I have tried using all types of merges, dropping duplicates from df2 and even using groupby. </p>
  
  <pre><code>pd.merge_asof(df1, df2, by=['Company','ID'], left_on='Date1', right_on='Date2', allow_exact_matches=False)
  </code></pre>
  
  <p>I have played around with other parameters for merge_asof i.e. direction='forward' and tolerance but it isn't working.
  I basically to pull in matches from df2 where the Date2 is before Date1 with no repeating dates/matches. In the case where Company = 'FF', I would prefer to match the record where Clicks is greater than 0 if possible.</p>
  
  <p>Expected output:</p>
  
  <pre><code>Company   Revenue     ID        Date1      Date2        Clicks
   XX       1000.0    12345x    2020-02-11   2020-01-10    0
   XX       6000.0    12345x    2020-01-02   2019-07-11    1
   AA       5000.0    12346a    2019-12-20   N/A           N/A
   BB       100.0     22345x    2019-11-07   N/A           N/A
   FF       18000.0   32345x    2020-01-11   2019-03-11    1
  </code></pre>