title: Pandas groupby and make set of items
body: <p>I am using pandas groupby and want to apply the function to make a set from the items in the group.</p>
  <p>The following results in <code>TypeError: 'type' object is not iterable</code>:</p>
  <pre><code>df = df.groupby('col1')['col2'].agg({'size': len, 'set': set})
  </code></pre>
  <p>But the following works:</p>
  <pre><code>def to_set(x):
      return set(x)
      
  df = df.groupby('col1')['col2'].agg({'size': len, 'set': to_set})
  </code></pre>
  <p>In my understanding the two expression are similar, what is the reason why the first does not work?</p>