title: Count unique elements row wise in an ndarray
body: <p>An extension to <a href="https://stackoverflow.com/questions/26958233/numpy-row-wise-unique-elements">this</a> question. In addition to having the unique elements row-wise, I want to have a similarly shaped array that gives me the count of unique values. For example, if the initial array looks like this:</p>
  
  <pre><code>a = np.array([[1,  2, 2, 3,  4, 5],
                [1,  2, 3, 3,  4, 5],
                [1,  2, 3, 4,  4, 5],
                [1,  2, 3, 4,  5, 5],
                [1,  2, 3, 4,  5, 6]])
  </code></pre>
  
  <p>I would like to get this as the output from the function:</p>
  
  <pre><code>np.array([[1,  2, 0, 1,  1, 1],
            [1,  1, 2, 0,  1, 1],
            [1,  1, 1, 2,  0, 1],
            [1,  1, 1, 1,  2, 0],
            [1,  1, 1, 1,  1, 1]])
  </code></pre>
  
  <p>In numpy v.1.9 there seems to be an additional argument <code>return_counts</code> that can return the counts in a flattened array. Is there some way this can be re-constructed into the original array dimensions with zeros where values were duplicated?</p>