0

I'm trying to understand the pros and cons of each technique and in some cases, I've found its easier to use multiindex over groupby. For instance, when I need to just print a particular grouping to excel, its easier to use multiindex and then to_excel rather than go through the extra step of casting the DataFrameGroupby object to Dataframe. I tried to do a google for "Pandas multiindex vs GroupBy", but didn't see any direct comparison between the two methods. Any insights are appreciated as I am in the learning process.

Sammy7
  • 21
  • 11
  • Thanks for the reference. – Sammy7 Jul 31 '19 at 21:16
  • I'd add that groupby is used together with aggregation, whereas multiindex is just reshaping the dataframe. From the [docs](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.groupby.html): "A groupby operation involves some combination of splitting the object, applying a function, and combining the results." – m13op22 Jul 31 '19 at 21:21

0 Answers0