title: Pandas GroupBy and add count of unique values as a new column
body: <h3>Problem</h3>
  <p>I'm trying to group a Pandas DataFrame by columns <code>day</code> and <code>source</code>, and then count unique instances of a 3rd (<code>timestamp</code>) for each group (to find out how many hits each source got per day), but I get this error (full traceback below):
  <code>TypeError: 'method' object is not subscriptable</code></p>
  <h3>Attempts</h3>
  <p>My code is:</p>
  <pre><code>df['timestamp_count'] = df.groupby([&quot;source&quot;, &quot;day&quot;]).agg({&quot;timestamp&quot;: &quot;nunique&quot;})
  </code></pre>
  <p>And ideally I'd like to get a result like this (including the new column, <code>timestamp_count</code>:</p>
  <pre><code>day    source    timestamp                timestamp_count
  1      facebook  2018-08-04 11:16:32.416  2
  1      facebook  2019-01-03 10:25:38.216  2
  1      twitter   2018-10-14 13:26:22.123  1
  2      facebook  2019-01-30 12:16:32.416  1
  </code></pre>
  <p>When I run <code>df.describe()</code>, I see that <code>source</code> is an object but <code>day</code> is an integer. Could this be part of the problem? Having looked at other questions, it seems probable that it is along those lines, yet none of them seem to throw the same input/error combination.</p>
  <p>Can anyone help a Python newbie? Many thanks!</p>
  <h3>Traceback</h3>
  <pre><code>---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-90-db5a002137ca&gt; in &lt;module&gt;
  ----&gt; 1 df['timestamp_count'] = (df.groupby[&quot;source&quot;, 
  &quot;day&quot;]).agg({&quot;timestamp&quot;: &quot;nunique&quot;})
  
  TypeError: 'method' object is not subscriptable
  </code></pre>