title: How to check if a combination of values in 2 columns is present in a pandas data frame
body: <p>I have 2 data frames. Title and section are two columns among others. 
  I need to check if the combination of particular title and section from one data frame is present in the second.</p>
  
  <p>E.g. Data frame <code>torange</code> has columns title, s_low, s_high and others; <code>usc</code> has columns title and section. </p>
  
  <p>If there's following row in <code>torange</code></p>
  
  <pre><code>title   s_low   s_high
    1        1      17
  </code></pre>
  
  <p>the code needs to check in <code>usc</code> if a row</p>
  
  <pre><code>title   section
   1        1
  </code></pre>
  
  <p>and a row </p>
  
  <pre><code>title   section
   1          17
  </code></pre>
  
  <p>exist; and create a new table to write the title, section, and the rest of the columns in <code>torange</code> by expanding the range between s_low and s_high in <code>usc</code>.</p>
  
  <p>I've written the below code but somehow it doesn't work/ stops after just a few iterations. I'm suspecting that there's something wrong in the counter for 'i', may be a syntax error. Also, it may be something to do with the syntax of <code>any()</code></p>
  
  <pre><code>import MySQLdb as db
  from pandas import DataFrame
  from pandas.io.sql import frame_query
  cnxn = db.connect('127.0.0.1','xxxxx','xxxxx','xxxxxxx', charset='utf8', use_unicode=True )
  torange = frame_query("SELECT title, s_low, s_high, post, pre, noy, rnum from torange", cnxn)
  usc = frame_query("SELECT title, section from usc", cnxn)
  
  i=0
  for row in torange:
      t =  torange.title[i]
      s_low = torange.s_low[i]
      s_high = torange.s_high[i]
      for row in usc:
          if (any(usc.title == t) &amp; any(usc.section == s_low)):
              print 't', t, 's_low' , s_low,'i', i
              if (any(usc.title == t) &amp; any(usc.section == s_high)):
                  print 't', t, 's_high', s_high, 'i',i
                  print i, '*******************match************************'
      i=i+1
  </code></pre>
  
  <p>(Please ignore the priint statements. This is part of a bigger task that I'm doing and prints are used just as checks to see what's happening. )</p>
  
  <p>Any help in this regard would be greatly appreciated.</p>