title: How to find rows of one dataframe in another dataframe?
body: <p>I have two pandas dataframes <code>df1</code> and <code>df2</code>. I need to select indices of rows in <code>df1</code>, whose (specific) column values are included in <code>df2</code>.</p>
  
  <p>This is my code:</p>
  
  <pre><code>selected_rows = []
  
  for i, rowi in df1.iterrows():
    for j, rowj in df2.iterrows():
      if (rowi['COL1']==rowj[COL1']) &amp; (rowi['COL2']==rowj['COL2']):
        selected_rows.append(i)
  </code></pre>
  
  <p>The problem is that <code>df1</code> is large, and the nested for.loop takes a lot of time. Is there any alternative solution, e.g. using masks?</p>
  
  <p>Sample data:</p>
  
  <pre><code>data1 = [['Alex',10,1],['Bob',12,1],['Clarke',13,4]]
  df1 = pd.DataFrame(data1,columns=['COL1','COL2','COL3'])
  
  data2 = [['Ted',10],['Bob',12],['Clarke',13]]
  df2 = pd.DataFrame(data2,columns=['COL1','COL2'])
  </code></pre>
  
  <p>The expected answer is: rows 1 and 2 (staring the count from 0).</p>