title: Normalize slices of a ndarray
body: <p>I have a 3 columns array. The first column of the array have values between 1 and 10. I need to extract all lines where the first column is 1 and normalize the third column of this slice of array. Then repeat the same thing for all rows for which the first column is equal to 2 etc.</p>
  
  <p>If I run this code, it leaves the array unchanged:</p>
  
  <pre><code>for u in np.unique(x[:,0]):
      mask= x[:, 0] == u
      x[mask][:,2]=x[mask][:,2]/np.sum((x[mask][:,2]))
  </code></pre>
  
  <p>If I run this other slice of code, I see that r (I placed a print r in the loop) actually work exactly as I want. The only point is that the original array x unchanged. </p>
  
  <pre><code>for u in np.unique(x[:,0]):
      r = x[x[:, 0] == u]
      r[:,2]=r[:,2]/np.sum((x[x[:,0]==u][:,2]))
  </code></pre>
  
  <p>Why is that? What am I doing wrong???</p>