SQL equivalent of 'exists'

User 1014 | 12/3/2014, 3:49:41 PM

Hi, is there an equivalent of the 'exists' operator for SFrames in GraphLab? I'd like to filter a table based on whether the value of one of its columns exists in a specific column of another table. An equivalent of the SQL 'exists' operator would allow me to do this in one shot. Thanks for your help.


User 398 | 12/3/2014, 6:11:14 PM

Hi there. You can achieve the same thing using the <a href="http://graphlab.com/products/create/docs/generated/graphlab.SFrame.filterby.html#graphlab.SFrame.filterby">SFrame.filter_by()</a> method. Have a look at the example below:

<pre class="CodeBlock"><code>import random

sf1 = gl.SFrame({'data': gl.SArray(range(0, 100))}) sf2 = gl.SFrame({'data': gl.SArray([random.randint(0, 100) for _ in range(0, 100)])})

sf1.filterby(sf_2['data'], 'data')</code></pre>

I hope that helps.

User 1014 | 12/3/2014, 7:21:04 PM

Yes, that helped! Thanks.