Searching rows of one dataframe in another dataframe in Python
<p>I have two data frames in python:</p>

<pre><code>  df1
       A     B     C
       1     1     0
       1     2     1 
       0     1     2
       .     .     .
       .     .     .

  df2
       T     W    S    Y
       7     4    5   [1]
       8     12   4   [0,7]
       10    14   6   [2,3]
</code></pre>

<p>I want to go through all rows of df1 and find the observations in df2 with the following characteristics:</p>

<pre><code>     (T &lt;= A) and (W &gt; A) and (S == B) and (sum(pd.Series(Y).isin([C])) != 0)
</code></pre>

<p>Obviously, using for loop is not efficient but could you please tell me how can I solve my problem? I've heard that I could vectorization technique like Matlab but I'm not sure if we have such technique in python or not.</p>

<p>You can do a merge of the two dataframes and filter the result. I am not sure how optimized it will be, but it will do the job faster than python for loops.</p>

python list search dataframe