title: Pandas GroupBy: comma separated list of sums
body: <p>I have the below <code>groupby</code> which is summing the Amounts at the &quot;ParentAccount&quot; level. I am trying to show on the same line the details behind that sum. I have the comma separated list of accounts showing next to the amount total but would also like to add in a single column that shows a comma separated sum at the account level.</p>
  <p>So for the below code I would have the following float strings in a separate column</p>
  <pre><code>ParentAccount 1: 3.75, 1
  ParentAccount 2: 14, 10.5
  </code></pre>
  <p>Not sure of the best way to go about doing this. I tried doing a merge of two separate <code>groupby</code>s but think there is probably a better way of doing this.</p>
  <pre><code>import pandas as pd
  
  data = {
          'ParentAccount': [1,1,1,2,2,2],
          'Account': ['A', 'A', 'C', 'D', 'D','E'],
          'Amount':  [1.5, 2.25, 1, 4.75, 9.25, 10.50],
          }
  
  df = pd.DataFrame(data)
  df_final = df.groupby('ParentAccount').agg({'Amount': 'sum', 'Account': lambda x: ','.join(x.unique()),}).add_suffix('-Net')
  
  print(df_final)
  </code></pre>