select identical entries in two pandas dataframe
<p>I have two dataframes. (a,b,c,d ) and (i,j,k) are the name columns dataframes</p>

<pre><code>df1 =

  a  b  c  d
  0  1  2  3
  0  1  2  3
  0  1  2  3

df2 =

  i  j  k  
  0  1  2  
  0  1  2  
  0  1  2  
</code></pre>

<p>I want to select the entries that df1 is df2
I want to obtain</p>

<pre><code> df1=   

  a  b  c  
  0  1  2  
  0  1  2  
  0  1  2  
</code></pre>

<p>Doing a column-wise comparison would give the desired result:</p>

<pre><code>df1 = df1[(df1.a == df2.i) &amp; (df1.b == df2.j) &amp; (df1.c == df2.k)][['a','b','c']]
</code></pre>

<p>You get only those rows from <code>df1</code> where the values of the first three columns are identical to those of <code>df2</code>.</p>

<p>Then you just select the rows <code>'a','b','c'</code> from <code>df1</code>.</p>

python pandas dataframe