Lerner Consulting Blogยท
Pandas groupby: Get a data frame instead of a series
TL;DR
Selecting a single column when grouping data in Pandas can return a Series rather than a DataFrame. Select the column using a one-element list instead to keep the result as a single-column DataFrame.