title: Construct two dimensional numpy array from indices and values of a one dimensional array
body: <p>Say I've got</p>
  
  <pre><code>Y = np.array([2, 0, 1, 1])
  </code></pre>
  
  <p>From this I want to obtain a matrix X with shape  <code>(len(Y), 3)</code>. In this particular case, the first row of X should have a one on the second index and zero otherwhise. The second row of X should have a one on the 0 index and zero otherwise. To be explicit:</p>
  
  <pre><code>X = np.array([[0, 0, 1], [1, 0, 0], [0, 1, 0], [0, 1, 0]])
  </code></pre>
  
  <p>How do I produce this matrix?
  I started with</p>
  
  <pre><code>X = np.zeros((Y.shape[0], 3))
  </code></pre>
  
  <p>but then couldn't figure out how to populate/fill in the ones from the list of indices</p>
  
  <p>As always, thanks for your time!</p>