title: Efficient Numpy 2D array construction from 1D array
body: <p>I have an array like this:</p>
  
  <pre><code>A = array([1,2,3,4,5,6,7,8,9,10])
  </code></pre>
  
  <p>And I am trying to get an array like this:</p>
  
  <pre><code>B = array([[1,2,3],
            [2,3,4],
            [3,4,5],
            [4,5,6]])
  </code></pre>
  
  <p>Where each row (of a fixed arbitrary width) is shifted by one. The array of A is 10k records long and I'm trying to find an efficient way of doing this in Numpy. Currently I am using vstack and a for loop which is slow. Is there a faster way?</p>
  
  <p>Edit:</p>
  
  <pre><code>width = 3 # fixed arbitrary width
  length = 10000 # length of A which I wish to use
  B = A[0:length + 1]
  for i in range (1, length):
      B = np.vstack((B, A[i, i + width + 1]))
  </code></pre>