title: Python numpy filter two-dimensional array by condition
body: <p>Python newbie here, I have read <a href="https://stackoverflow.com/questions/26154711/filter-rows-of-a-numpy-array">Filter rows of a numpy array?</a> and the doc but still can't figure out how to code it the python way.</p>
  
  <p>Example array I have: (the real data is 50000 x 10)</p>
  
  <pre><code>a = numpy.asarray([[2,'a'],[3,'b'],[4,'c'],[5,'d']])
  filter = ['a','c']
  </code></pre>
  
  <p>I need to find all rows in <code>a</code> with <code>a[:, 1] in filter</code>. Expected result:</p>
  
  <pre><code>[[2,'a'],[4,'c']]
  </code></pre>
  
  <p>My current code is this:</p>
  
  <pre><code>numpy.asarray([x for x in a if x[1] in filter ])
  </code></pre>
  
  <p>It works okay but I have read somewhere that it is not efficient.  What is the proper numpy method for this?</p>
  
  <h3>Edit:</h3>
  
  <p>Thanks for all the correct answers!  Unfortunately I can only mark one as accepted answer.  I am surprised that <code>numpy.in1d</code> is not turned up in google searchs for <code>numpy filter 2d array</code>.</p>