The DataFrameGroupBy should get a new method nlargest to allow selecting the N largest rows for each group.

Currently this is doable by using df.sort_values(...).groupby(...).head(n) but I want to use the keep='all' parameter of nlargest which cannot be obtained with head

Comment From: yoch

In fact, this can be done exactly in the same way than SeriesGroupBy.nlargest and SeriesGroupBy.nsmallest

https://github.com/pandas-dev/pandas/blob/4bfe3d07b4858144c219b9346329027024102ab6/pandas/core/groupby/generic.py#L744-L760

Comment From: lorentzbao

If still open, I would like to work on this issue.

Comment From: lorentzbao

take