title: Numpy.where used with list of values
body: <p>I have a 2d and 1d array. I am looking to find the two rows that contain at least once the values from the 1d array as follows:</p>
  
  <pre><code>import numpy as np
  
  A = np.array([[0, 3, 1],
             [9, 4, 6],
             [2, 7, 3],
             [1, 8, 9],
             [6, 2, 7],
             [4, 8, 0]])
  
  B = np.array([0,1,2,3])
  
  results = []
  
  for elem in B:
      results.append(np.where(A==elem)[0])
  </code></pre>
  
  <p>This works and results in the following array:</p>
  
  <pre><code>[array([0, 5], dtype=int64),
   array([0, 3], dtype=int64),
   array([2, 4], dtype=int64),
   array([0, 2], dtype=int64)]
  </code></pre>
  
  <p>But this is probably not the best way of proceeding. Following the answers given in this question (<a href="https://stackoverflow.com/questions/44921316/search-numpy-array-with-multiple-values">Search Numpy array with multiple values</a>) I tried the following solutions:</p>
  
  <pre><code>out1 = np.where(np.in1d(A, B))
  
  num_arr = np.sort(B)
  idx = np.searchsorted(B, A)
  idx[idx==len(num_arr)] = 0 
  out2 = A[A == num_arr[idx]]
  </code></pre>
  
  <p>But these give me incorrect values:</p>
  
  <pre><code>In [36]: out1
  Out[36]: (array([ 0,  1,  2,  6,  8,  9, 13, 17], dtype=int64),)
  
  In [37]: out2
  Out[37]: array([0, 3, 1, 2, 3, 1, 2, 0])
  </code></pre>
  
  <p>Thanks for your help</p>