title: Aggregate a Dask dataframe and produce a dataframe of aggregates
body: <p>I have a Dask dataframe that looks like this:</p>
  
  <pre><code>url     referrer    session_id ts                  customer
  url1    ref1        xxx        2017-09-15 00:00:00 a.com
  url2    ref2        yyy        2017-09-15 00:00:00 a.com
  url2    ref3        yyy        2017-09-15 00:00:00 a.com
  url1    ref1        xxx        2017-09-15 01:00:00 a.com
  url2    ref2        yyy        2017-09-15 01:00:00 a.com
  </code></pre>
  
  <p>I want to group the data on url and timestamp, aggregate column values and produce a dataframe that would look like this instead:</p>
  
  <pre><code>customer url    ts                  page_views visitors referrers
  a.com    url1   2017-09-15 00:00:00 1          1        [ref1]
  a.com    url2   2017-09-15 00:00:00 2          2        [ref2, ref3]
  </code></pre>
  
  <p>In Spark SQL, I can do this as follows:</p>
  
  <pre><code>select 
      customer,
      url,
      ts,
      count(*) as page_views,
      count(distinct(session_id)) as visitors,
      collect_list(referrer) as referrers
  from df
  group by customer, url, ts
  </code></pre>
  
  <p>Is there any way I can do it with Dask dataframes? I tried, but I can only calculate the aggregated columns separately, as follows:</p>
  
  <pre><code># group on timestamp (rounded) and url
  grouped = df.groupby(['ts', 'url'])
  
  # calculate page views (count rows in each group)
  page_views = grouped.size()
  
  # collect a list of referrer strings per group
  referrers = grouped['referrer'].apply(list, meta=('referrers', 'f8'))
  
  # count unique visitors (session ids)
  visitors = grouped['session_id'].count()
  </code></pre>
  
  <p>But I can't seem to find a good way to produce a combined dataframe that I need.</p>