Return dataframe object from pandas groupby() instead of series or groupby object November 15, 2021 by admin Use double square brackets around ‘Number’, i.e.: df.groupby(['Name', 'Fruit'])[['Number']].agg('sum')