title: Numpy 3d array indexing
body: <p>I have a 3d numpy array (<strong>n_samples x num_components x 2</strong>) in the example below <em>n_samples</em> = 5 and <em>num_components</em> = 7.</p>
  
  <p>I have another array (<strong>indices</strong>) which is the selected component for each sample which is of shape (<em>n_samples</em>,).</p>
  
  <p>I want to select from the data array given the indices so that the resulting array is <strong>n_samples x 2</strong>.</p>
  
  <p>The code is below:</p>
  
  <pre><code>import numpy as np
  np.random.seed(77)
  data=np.random.randint(low=0, high=10, size=(5, 7, 2))
  indices = np.array([0, 1, 6, 4, 5])
  #how can I select indices from the data array?
  </code></pre>
  
  <p>For example for data 0, the selected component should be the 0th and for data 1 the selected component should be 1.</p>
  
  <p>Note that I can't use any for loops because I'm using it in Theano and the solution should be solely based on numpy.</p>