title: Getting the indices of several elements in a NumPy array at once
body: <p>Is there any way to get the indices of several elements in a NumPy array at once?</p>
  <p>E.g.</p>
  <pre><code>import numpy as np
  a = np.array([1, 2, 4])
  b = np.array([1, 2, 3, 10, 4])
  </code></pre>
  <p>I would like to find the index of each element of <code>a</code> in <code>b</code>, namely: <code>[0,1,4]</code>.</p>
  <p>I find the solution I am using a bit verbose:</p>
  <pre><code>import numpy as np
  
  a = np.array([1, 2, 4])
  b = np.array([1, 2, 3, 10, 4])
  
  c = np.zeros_like(a)
  for i, aa in np.ndenumerate(a):
      c[i] = np.where(b == aa)[0]
      
  print('c: {0}'.format(c))
  </code></pre>
  <p>Output:</p>
  <pre><code>c: [0 1 4]
  </code></pre>