title: In Python / numpy, how do I unravel / split an array according to its first column, which is an index?
body: <p>This question is closely related to <a href="https://stackoverflow.com/questions/7662458/how-to-split-an-array-according-to-a-condition-in-numpy">How to split an array according to a condition in numpy?</a> but I am looking for a more general way to split an array given an unknown number of indices:</p>
  
  <pre><code>import numpy as np
  a=np.arange(10,40).reshape(10,3)
  b=np.array([[1],[1],[1],[2],[2],[3],[3],[4],[4],[5]])
  c=np.hstack((b,a))
  
  array([[ 1, 10, 11, 12],
         [ 1, 13, 14, 15],
         [ 1, 16, 17, 18],
         [ 2, 19, 20, 21],
         [ 2, 22, 23, 24],
         [ 3, 25, 26, 27],
         [ 3, 28, 29, 30],
         [ 4, 31, 32, 33],
         [ 4, 34, 35, 36],
         [ 5, 37, 38, 39]])
  </code></pre>
  
  <p>I'd like to split this up into a 1x2x2 array according to the first column, thus:</p>
  
  <pre><code>array([[[ 1, 10, 11, 12],
          [ 1, 13, 14, 15],
          [ 1, 16, 17, 18]],
  
         [[ 2, 19, 20, 21],
          [ 2, 22, 23, 24]],
  
         [[ 3, 25, 26, 27],
          [ 3, 28, 29, 30]],
  
         [[ 4, 31, 32, 33],
          [ 4, 34, 35, 36]],
  
         [[ 5, 37, 38, 39]]])
  </code></pre>
  
  <p>I am new to Python, so thank you in advance for your help!</p>