title: stratified sampling in numpy
body: <p>In numpy I have a dataset like this. The first two columns are indices. I can divide my dataset into blocks via the indices, i.e. first block is 0 0 second block is 0 1 third block 0 2 then 1 0, 1 1, 1 2 and so on and so forth. Each block has at least two elements. The numbers in the indices columns can vary</p>
  
  <p>I need to split the dataset along these blocks 80%-20% randomly such that after the split each block in both datasets has at least 1 element. How could I do that?</p>
  
  <pre><code>indices | real data
          |
  0   0   | 43.25 665.32 ...  } 1st block
  0   0   | 11.234            }
  0   1     ...               } 2nd block
  0   1                       } 
  0   2                       } 3rd block
  0   2                       }
  1   0                       } 4th block
  1   0                       }
  1   0                       }
  1   1                       ...
  1   1                       
  1   2
  1   2
  2   0
  2   0 
  2   1
  2   1
  2   1
  ...
  </code></pre>