title: 'Length of values does not match length of index' on a groupby
body: <p>I am having a strange bug with a pandas groupby in one of my databricks notebook.</p>
  <p>Data are confidential, so this is a dummy <strong>illustration</strong> of my bug (<em>the dataframe df is actually the result from a merge of two other dataframe</em>).</p>
  <p>If you want to reproduce the dataframe :</p>
  <pre><code>data = {'group1':  ['a', 'b','a','a','a'],
          'group2': ['f', 'f', 'f' , 'f', 'f'],
           'aggregate': ['1', '2','3','4','5'],}
  df = pd.DataFrame (data, columns = ['group1','group2','aggregate'])
  </code></pre>
  <p>At this stage , the dataframe df is displayed correctly. Now i am doing a groupby :</p>
  <pre><code>agg = df.groupby(['group2', 'group1'],  as_index=False).agg({'aggregate':', '.join})
  </code></pre>
  <p>I should be getting this :</p>
  <p><a href="https://i.stack.imgur.com/lByWR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lByWR.png" alt="enter image description here" /></a></p>
  <p>But I am getting this :</p>
  <blockquote>
  <p>ValueError: Length of values does not match length of index</p>
  </blockquote>
  <p>Only ways &quot;to make it work&quot; is :</p>
  <p><strong>Fix 1 :</strong>
  agg = df.groupby(['group2', 'group1'],  as_index=True).agg({'aggregate':', '.join}).reset_index()</p>
  <p>And i am getting this :</p>
  <p><a href="https://i.stack.imgur.com/LGDAB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LGDAB.png" alt="group2 group1   aggregate
  0      f      a  1, 3, 4, 5
  1      f      b           2
  2      f                NaN" /></a></p>
  <p><strong>Fix 2</strong> :
  After the initial merge, &quot;reset the dataframe&quot;, to have a new fresh one.
  This works perfectly but is not really nice.</p>
  <pre><code>df = pd.DataFrame.from_dict(drift.to_dict())
  </code></pre>
  <p>Is my data somehow corrupted ? How ?</p>
  <p>Any level of feedback would be much appreciated (whether you know the the reason of the bug - which would be great! - or not), just so that I understand a bit better what could be happening behind the scenes.</p>
  <p>Very much looking forward any suggestion or opinion here. Thank you !</p>