title: Selecting multiple slices from a numpy array at once
body: <p>I'm looking for a way to select multiple slices from a numpy array at once. Say we have a 1D data array and want to extract three portions of it like below:</p>
  
  <pre><code>data_extractions = []
  
  for start_index in range(0, 3):
      data_extractions.append(data[start_index: start_index + 5])
  </code></pre>
  
  <p>Afterwards <code>data_extractions</code> will be:</p>
  
  <pre><code>data_extractions = [
      data[0:5],
      data[1:6],
      data[2:7]
  ]
  </code></pre>
  
  <p>Is there any way to perform above operation without the for loop? Some sort of indexing scheme in numpy that would let me select multiple slices from an array and return them as that many arrays, say in an n+1 dimensional array?</p>
  
  <hr>
  
  <p>I thought maybe I can replicate my data and then select a span from each row, but code below throws an IndexError</p>
  
  <pre><code>replicated_data = np.vstack([data] * 3)
  data_extractions = replicated_data[[range(3)], [slice(0, 5), slice(1, 6), slice(2, 7)]
  </code></pre>