title: Pandas groupby and aggregate: produce unique single values for some cells
body: <p>All,</p>
  <p>I have the following pd.DataFrame():</p>
  <pre><code>df = pd.DataFrame({'fruit': ['carrot','carrot','apple','apple', 'tomato'],
                     'taste': ['sweet','sweet','sweet','bitter','bitter'],
                     'quality': ['good','poor','rotten','good','good']})
  </code></pre>
  <p>Which looks like this:</p>
  <pre><code>    fruit   taste quality
  0  carrot   sweet    good
  1  carrot   sweet    poor
  2   apple   sweet  rotten
  3   apple  bitter    good
  4  tomato  bitter    good
  </code></pre>
  <p>I apply grouby and agg like this:</p>
  <pre><code>df.groupby('fruit').agg(pd.Series.tolist)
  </code></pre>
  <p>producing:</p>
  <pre><code>                  taste         quality
  fruit                                  
  apple   [sweet, bitter]  [rotten, good]
  carrot   [sweet, sweet]    [good, poor]
  tomato         [bitter]          [good]
  </code></pre>
  <p>But what I want is:</p>
  <pre><code>                  taste         quality
  fruit                                  
  apple   [sweet, bitter]  [rotten, good]
  carrot            sweet    [good, poor]
  tomato           bitter            good
  </code></pre>
  <p>In words: I want to only aggregate the entries that have multiple different values, but when the list only contains the same unique item, I want it to just contain said item. Is there a nice way of doing this (preferable by not going through all cells of the df, mine is rather big, but perhaps it is the only way?)? Apologies if I'm unclear, I struggle to express this in words (hence the difficult title also).</p>
  <p>Thank you in advance.</p>