title: Find index of Python array in another array
body: <p>Say I have two <code>Numpy</code> arrays:</p>
  
  <pre><code>a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
  b = np.array([7, 8, 9])
  </code></pre>
  
  <p>How do I easily find where <code>b</code> exists in <code>a</code>? In this case I want <code>2</code>. <code>numpy.where()</code> returns useful information but it still has to be processed. I have written a function for that, as can be seen below, but there must be an easier way.</p>
  
  <pre><code>def find_vertical_array_index(a, b):
      """Find array in another array.
  
      Parameters
      ----------
      a: numpy array
      Array to find array in.
      b: numpy array
           Array to find array. Must have dimensions 1 by n.
  
      Returns
      -------
      Integer value of index where b first occurs in a.
  
      Notes
      -----
      Only searches through the array vertically and returns the first index.
      If array does not occur, nothing is returned.
  
      Examples
      --------
      &gt;&gt;&gt; x = np.array([[5, 3, 1, 1], [9, 9, 9, 8], [9, 3, 7, 9]])
      &gt;&gt;&gt; y = np.array([9, 9, 9, 8])
      &gt;&gt;&gt; find_vertical_array_index(x, y)
      1
  
      &gt;&gt;&gt; x = np.array([[9, 9, 9, 8], [9, 9, 9, 8], [9, 3, 7, 9]])
      &gt;&gt;&gt; y = np.array([9, 9, 9, 9])
      0
      """
      try:
          index = list(Counter(np.where(a == b)[0]).values()).index(len(b))
      except ValueError:
          pass
      return list(Counter(np.where(a == b)[0]).keys())[index]
  </code></pre>