title: How to get unique values from pandas series using aggregate method?
body: <p>Consider this <code>dataframe</code></p>
  
  <pre><code>df = pandas.DataFrame(numpy.random.randint(0,100,size=(200, 4)), columns=list('ABCD'))
  df['E'] = list(numpy.arange(1001, 1021)) * 10
  df['F'] = ['c', 'b', 'b', 'a', 'd'] * 20 + ['d', 'a', 'b', 'b', 'c'] * 20
  </code></pre>
  
  <p>I want to group by column 'E', but I want to aggregate some functions. For example <code>sum</code> values from column A, B, D and <code>count</code> column C. With column 'F' I want to get unique values in an array.</p>
  
  <p>So I tried:</p>
  
  <pre><code>params = {
    'A': 'sum',
    'B': 'sum',
    'C': 'count',
    'D': 'sum',
    'F': pandas.Series.unique
  }
  df_ = df.groupby('E').agg(params).reset_index()
  </code></pre>
  
  <p>Which returns an Error: <code>Exception: Must produce aggregated value</code></p>
  
  <p>I tried this code because in another example it works. Since then, I have been trying the same method to filter different data, but without results.</p>
  
  <p>If I use <code>pandas.Series.nunique</code> or <code>lambda x: x.nunique()</code> it counts unique values and it works ok. But, how can I get unique values using pandas <code>aggregate</code> method?</p>
  
  <p>To get this work, I wrote a function with a <code>for loop</code> that takes a column name as a parameter. However, I hope this could have a better approach.</p>