Groupby
Groupby
s are an incredibly powerful and fast way to perform calculations, transformations, and filter your data.
It follows the mantra of split-apply-combine where the dataset is split into multiple partitions based on unique values of a variable or variables, a function is applied on each partition separately, and all the results are combined together at the end.
This exercise is part of the course
Python for R Users
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Mean tip by sex
print(tips____(____)[____].____)