How to check values of column in one dataframe available or not in column of another dataframe?
<p>I have two dataframes-</p>

<pre><code>df1_data = {'sym1' :{0:'abc a01',1:'pqr q02',2:'xyz y03',3:'mno o12',4:'lmn l45'}}
df1 = pd.DataFrame(df1_data)
print df1

df2_data = {'sym2' :{0:'abc a01',1:'xxx p0',2:'xyz y03',3:'mno o12',4:'lmn l45',5:'rrr r1',6:'kkk k3'}}
df2 = pd.DataFrame(df2_data)
print df2
</code></pre>

<p><strong>output-</strong></p>

<pre><code>      sym1
0  abc a01
1  pqr q02
2  xyz y03
3  mno o12
4  lmn l45
      sym2
0  abc a01
1   xxx p0
2  xyz y03
3  mno o12
4  lmn l45
5   rrr r1
6   kkk k3
</code></pre>

<p>I want to check sym2 column values available or not in df2 dataframes sym1 column. If symbols in sym2 column are not available then I want list of that symbols which are not available in sym1 column. If all symbols are available then list must be empty.</p>

<p><strong>Expected Result-</strong></p>

<pre><code>list -&gt; ['xxx p0','rrr r1','kkk k3']
</code></pre>

<p>You can use <a href="http://pandas.pydata.org/pandas-docs/stable/indexing.html#boolean-indexing" rel="nofollow"><code>boolean indexing</code></a> with <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.isin.html" rel="nofollow"><code>isin</code></a>, then select by <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.ix.html" rel="nofollow"><code>ix</code></a> and convert to <code>list</code> by <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.tolist.html" rel="nofollow"><code>tolist</code></a>:</p>

<pre><code>print (~df2.sym2.isin(df1.sym1))
0    False
1     True
2    False
3    False
4    False
5     True
6     True
Name: sym2, dtype: bool

print (df2.ix[~df2.sym2.isin(df1.sym1), 'sym2'])
1    xxx p0
5    rrr r1
6    kkk k3
Name: sym2, dtype: object

print (df2.ix[~df2.sym2.isin(df1.sym1), 'sym2'].tolist())
['xxx p0', 'rrr r1', 'kkk k3']
</code></pre>

python pandas dataframe