title: Combine pandas dataframe cells in case of identical values
body: <p>I'm trying to make a new dataframe where, if a 'type' occurs more than once, the contents of the 'country' cells and the 'year' cells of those rows are combined in one row (the 'how' column behaves like the 'type' column: if the types are similar, the hows are as well).</p>
  
  <p>My pd dataframe looks as follows, df:</p>
  
  <pre><code>   type   country   year   how
  0  't1'    'UK'    '2009'  'S' 
  1  't2'    'GER'   '2010'  'D'
  2  't2'    'USA'   '2011'  'D'
  3  't3'    'AUS'   '2012'  'F'
  4  't4'    'CAN'   '2013'  'R'
  5  't5'    'SA'    '2014'  'L'
  6  't5'    'RU'    '2015'  'L'
  </code></pre>
  
  <p>df2 should look like this:</p>
  
  <pre><code>   type   country        year         how
  0  't1'    'UK'         '2009'        'S' 
  1  't2'    'GER, USA'   '2010, 2011'  'D'
  2  't3'    'AUS'        '2012'        'F'
  3  't4'    'CAN'        '2013'        'R'
  4  't5'    'SA, RU'     '2014, 2015'  'L'
  </code></pre>
  
  <p>I'm pretty sure a group by on 'type' (or type and how) is necessary. Using first() for example removes the second of the similar type rows. Is there some handy way to instead combine the cells (strings)? Thanks in advance.</p>