title: How to create multiple list aggregations using groupby on a pandas dataframe in Python?
body: <p>Take the following example pandas DataFrame:</p>
  <pre><code>df = pd.DataFrame({&quot;id&quot;: [1, 2, 3, 4, 5, 6],
                     &quot;start&quot;: [&quot;jan1&quot;, &quot;jan1&quot;, &quot;jan4&quot;, &quot;feb17&quot;, &quot;jan4&quot;, &quot;mar3&quot;],
                     &quot;end&quot;: [&quot;jan3&quot;, &quot;jan3&quot;, &quot;jan21&quot;, &quot;feb17&quot;, &quot;jan21&quot;, &quot;mar4&quot;],
                     &quot;duration&quot;: [2, 2, 17, 0, 17, 1],
                     &quot;case_id&quot;: [&quot;case1&quot;, &quot;case43&quot;, &quot;case6&quot;, &quot;case1&quot;, &quot;case22&quot;, &quot;case69&quot;]
                    })
  </code></pre>
  <p>I want to use a pandas groupby operation on columns <code>start</code>, <code>end</code> and <code>duration</code> to perform two list aggregations on the dataframe:</p>
  <ul>
  <li>a list of the <code>id</code> values for each group</li>
  <li>a list of the <code>case_id</code> values for each group</li>
  </ul>
  <p>My desired output would look like this:</p>
  <pre><code>start    end    duration    ids    cases
  jan1     jan3   2           [1, 2] [case1, case43]
  jan4     jan21  17          [3, 5] [case6, case22]
  feb17    feb17  0           [4]    [case1]
  mar3     mar4   1           [6]    [case69]
  </code></pre>
  <p>How to do this efficiently using pandas groupby?</p>
  <p>I know that if I would need only one aggregation I could do it like this:</p>
  <pre><code>df = df.groupby(['start', 'end', 'duration'])['id'].apply(list).to_frame()
  </code></pre>
  <p>How to do this for multiple list aggregations? And if there are multiple options, what would be the least time consuming? (the DataFrames I'm transforming are quite large)</p>