<p>Hi, I want to extract elements of an array (say, a) that are contained in<br>another array (say, b). That is, if a=array([1,1,2,3,3,4]), b=array([1,4]),<br>then I want array([1,1,4]).</p>
<p>I did the following but the speed is very slow (maybe because a is very long):</p>
<p>c=array([])<br>for x in b:<br>   c=append(c,a[a==x])</p>
<p>any way to speed it up?</p>
<p>Thanks!<br>-Ning</p>