title: Numpy: Set 1 element of each row based on a column index array
body: <p>Suppose I have the following arrays:</p>
  
  <pre><code>a = np.zeros([4,3])
  b = np.asarray([0,1,2,1])
  </code></pre>
  
  <p>Now how can I set an element on each row in array a to 1 based on the column index indicated by array b? What I need is an array c which looks like below:</p>
  
  <pre><code>[[ 1.  0.  0.]
   [ 0.  1.  0.]
   [ 0.  0.  1.]
   [ 0.  1.  0.]]
  </code></pre>
  
  <p>Alternatively, is there a way to directly convert array b to array c?</p>