This anwser said that I can use df.groupby('id')['value'].nlargest(30)to get top30 rows for each group.
But how to get the rows form top2 to top31 for each group? Is there a function that can do the similar thing like pandas.Series.nlargest
How to keep top [2-31] rows of each group in a pandas data frame?
56 views Asked by Dawei At
1
Try
applyand.ilocto get , for example you want 1:30