title: Numpy assign an array value based on the values of another array with column selected based on a vector
body: <p>I have a 2 dimensional array</p>
  
  <pre><code>X
  array([[2, 3, 3, 3],
         [3, 2, 1, 3],
         [2, 3, 1, 2],
         [2, 2, 3, 1]])
  </code></pre>
  
  <p>and a 1 dimensional array </p>
  
  <pre><code>y
  array([1, 0, 0, 1])
  </code></pre>
  
  <p>For each row of X, i want to find the column index where X has the lowest value and y has a value of 1, and set the corresponding row column pair in a third matrix to 1</p>
  
  <p>For example, in case of the first row of X, the column index corresponding to the minimum X value (for the first row only) and y = 1 is 0, then I want Z[0,0]  = 1 and all other Z[0,i] = 0.
  Similarly, for the second row,  column index 0 or 3 gives the lowest X value with y = 1. Then i want either Z[1,0] or Z[1,3] = 1 (preferably Z[1,0] = 1 and all other Z[1,i] = 0, since 0 column is the first occurance)</p>
  
  <p>My final Z array will look like</p>
  
  <pre><code>Z
  array([[1, 0, 0, 0],
         [1, 0, 0, 0],
         [1, 0, 0, 0],
         [0, 0, 0, 1]])
  </code></pre>