Is there an “ungroup by” operation opposite to .groupby in pandas?

The rough equivalent is .reset_index(), but it may not be helpful to think of it as the “opposite” of groupby().

You are splitting a string in to pieces, and maintaining each piece’s association with ‘family’. This old answer of mine does the job.

Just set ‘family’ as the index column first, refer to the link above, and then reset_index() at the end to get your desired result.

Leave a Comment