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
            Asked
            
        
        
            Active
            
        
            Viewed 51 times
        
    1 Answers
3
            Try apply and .iloc to get , for example you want 1:30
df.sort_values('value').groupby('id').value.apply(lambda x : x.iloc[1:30])
 
    
    
        BENY
        
- 317,841
- 20
- 164
- 234
- 
                    1But the question was from nlargest right? `top 2 - 31`. Maybe you need to `sort_values`? – Bharath M Shetty Nov 21 '17 at 15:30
- 
                    @Dawei Yw~ have a nice day :-) – BENY Nov 21 '17 at 15:38
