title: Compare Python Pandas DataFrames for matching rows
body: <p>I have this DataFrame (<code>df1</code>) in Pandas:</p>
  
  <pre><code>df1 = pd.DataFrame(np.random.rand(10,4),columns=list('ABCD'))
  print df1
  
         A         B         C         D
  0.860379  0.726956  0.394529  0.833217
  0.014180  0.813828  0.559891  0.339647
  0.782838  0.698993  0.551252  0.361034
  0.833370  0.982056  0.741821  0.006864
  0.855955  0.546562  0.270425  0.136006
  0.491538  0.445024  0.971603  0.690001
  0.911696  0.065338  0.796946  0.853456
  0.744923  0.545661  0.492739  0.337628
  0.576235  0.219831  0.946772  0.752403
  0.164873  0.454862  0.745890  0.437729
  </code></pre>
  
  <p>I would like to check if any row (all columns) from another dataframe (<code>df2</code>) are present in <code>df1</code>. Here is <code>df2</code>:</p>
  
  <pre><code>df2 = df1.ix[4:8]
  df2.reset_index(drop=True,inplace=True)
  df2.loc[-1] = [2, 3, 4, 5]
  df2.loc[-2] = [14, 15, 16, 17]
  df2.reset_index(drop=True,inplace=True)
  print df2
  
             A         B         C         D
      0.855955  0.546562  0.270425  0.136006
      0.491538  0.445024  0.971603  0.690001
      0.911696  0.065338  0.796946  0.853456
      0.744923  0.545661  0.492739  0.337628
      0.576235  0.219831  0.946772  0.752403
      2.000000  3.000000  4.000000  5.000000
     14.000000 15.000000 16.000000 17.000000
  </code></pre>
  
  <p>I tried using <code>df.lookup</code> to search for one row at a time. I did it this way:</p>
  
  <pre><code>list1 = df2.ix[0].tolist()
  cols = df1.columns.tolist()
  print df1.lookup(list1, cols)
  </code></pre>
  
  <p>but I got this error message:</p>
  
  <pre><code>  File "C:\Users\test.py", line 19, in &lt;module&gt;
      print df1.lookup(list1, cols)
    File "C:\python27\lib\site-packages\pandas\core\frame.py", line 2217, in lookup
      raise KeyError('One or more row labels was not found')
  KeyError: 'One or more row labels was not found'
  </code></pre>
  
  <p>I also tried <code>.all()</code> using:</p>
  
  <pre><code>print (df2 == df1).all(1).any()
  </code></pre>
  
  <p>but I got this error message:</p>
  
  <pre><code>  File "C:\Users\test.py", line 12, in &lt;module&gt;
      print (df2 == df1).all(1).any()
    File "C:\python27\lib\site-packages\pandas\core\ops.py", line 884, in f
      return self._compare_frame(other, func, str_rep)
    File "C:\python27\lib\site-packages\pandas\core\frame.py", line 3010, in _compare_frame
      raise ValueError('Can only compare identically-labeled '
  ValueError: Can only compare identically-labeled DataFrame objects
  </code></pre>
  
  <p>I also tried <code>isin()</code> like this:</p>
  
  <pre><code>print df2.isin(df1)
  </code></pre>
  
  <p>but I got <code>False</code> everywhere, which is not correct:</p>
  
  <pre><code>    A      B      C      D
  False  False  False  False
  False  False  False  False
  False  False  False  False
  False  False  False  False
  False  False  False  False
  False  False  False  False
  False  False  False  False
  False  False  False  False
  False  False  False  False
  False  False  False  False
  </code></pre>
  
  <p>Is it possible to search for a set of rows in a DataFrame, by comparing it to another dataframe's rows?</p>
  
  <p>EDIT:
  Is is possible to drop <code>df2</code> rows if those rows are also present in <code>df1</code>?</p>