title: Number of unique values per column by group
body: <p>Consider the following dataframe:</p>
  
  <pre><code>      A      B  E
  0   bar    one  1
  1   bar  three  1
  2  flux    six  1
  3  flux  three  2
  4   foo   five  2
  5   foo    one  1
  6   foo    two  1
  7   foo    two  2
  </code></pre>
  
  <p>I would like to find, for each value of <code>A</code>, the number of unique values in the other columns.</p>
  
  <ol>
  <li><p>I thought the following would do it:</p>
  
  <pre><code>df.groupby('A').apply(lambda x: x.nunique())
  </code></pre>
  
  <p>but I get an error:</p>
  
  <pre><code>AttributeError: 'DataFrame' object has no attribute 'nunique'
  </code></pre></li>
  <li><p>I also tried with:</p>
  
  <pre><code>df.groupby('A').nunique()
  </code></pre>
  
  <p>but I also got the error:</p>
  
  <pre><code>AttributeError: 'DataFrameGroupBy' object has no attribute 'nunique'
  </code></pre></li>
  <li><p>Finally I tried with:</p>
  
  <pre><code>df.groupby('A').apply(lambda x: x.apply(lambda y: y.nunique()))
  </code></pre>
  
  <p>which returns:</p>
  
  <pre><code>      A  B  E
  A            
  bar   1  2  1
  flux  1  2  2
  foo   1  3  2
  </code></pre>
  
  <p>and seems to be correct. Strangely though, it also returns the column <code>A</code> in the result. Why?</p></li>
  </ol>