title: Adding new column to pandas DataFrame results in NaN
body: <p>I have a pandas DataFrame <code>data</code> with the following transaction data:</p>
  
  <pre><code>           A         date
  0      M000833  2016-08-01
  1      M000833  2016-08-01
  2      M000833  2016-08-02
  3      M000833  2016-08-02 
  4      M000511  2016-08-05
  </code></pre>
  
  <p>I want a new column with the count of number of visits (multiple visits per day should be treated as 1) per consumer. </p>
  
  <p>So I tried this:</p>
  
  <pre><code>import pandas as pd
  data['noofvisits'] = data.groupby(['A'])['date'].nunique()
  </code></pre>
  
  <p>When I just run the statement without assigning it to the DataFrame, I get a pandas series with the desired output. However, the above statement result in:</p>
  
  <pre><code>           A         date       noofvisits
  0      M000833  2016-08-01         NaN         
  1      M000833  2016-08-01         NaN
  2      M000833  2016-08-02         NaN
  3      M000833  2016-08-02         NaN
  4      M000511  2016-08-05         NaN
  </code></pre>
  
  <p>The expected output is:</p>
  
  <pre><code>           A         date       noofvisits
  0      M000833  2016-08-01         2         
  1      M000833  2016-08-01         2
  2      M000833  2016-08-02         2
  3      M000833  2016-08-02         2
  4      M000511  2016-08-05         1
  </code></pre>
  
  <p>What is wrong with this approach? Why does the column noofvisits results in NAs rather than the count values? </p>