title: Slicing a different range at each index of a multidimensional numpy array
body: <p>I have an <code>m</code> x <code>n</code> numpy array <code>arr</code>, and for each column of <code>arr</code>, I have a given range of rows that I want to access.<br>
  I have an <code>n</code> x <code>1</code> array <code>vec</code> that describes when this range starts.<br>
  The range has some constant duration <code>d</code>.  </p>
  
  <p>How can I extract this <code>d</code> x <code>n</code> array of interest efficiently?<br>
  Can this be done by clever slicing?   </p>
  
  <p>My initial thought was to try something like:</p>
  
  <pre><code>arr = np.tile(np.arange(10),(4,1)).T
  vec = np.array([3,4,5,4])
  d = 3
  vec_2 = vec+d
  out = arr[vec:vec2,np.arange(n)]
  </code></pre>
  
  <p>But this gives the following error:  </p>
  
  <blockquote>
    <p>TypeError: only integer scalar arrays can be converted to a scalar index   </p>
  </blockquote>
  
  <p>The desired output would be the following array:</p>
  
  <pre><code>array([[3, 4, 5, 4],
         [4, 5, 6, 5],
         [5, 6, 7, 6],
         [6, 7, 8, 7])
  </code></pre>
  
  <p>I could loop over <code>d</code>, but performance is important for this piece of code so I would prefer to vectorize it.</p>