Skip to content

Tag: pandas-groupby

Group by from wide form in Pandas

I have a DataFrame like this one: I want to find out the characteristics of the Disloyal and Not Satisfied customers that are between 30 and 40 years old, grouping them by the service they have rated: I suspect I have to use melt but I can’t figure out how to groupby from there. Answer With the followin…

Pandas groupby – Find mean of first 10 items

I have 30 items in each group. To find mean of entire items, I use this code. That returns a value like this. However, I would like to find the mean of the first 10 items in the group instead of the entire items. That code return only a single Value instead of a pandas series. So I’m getting errors