Category "top-n"

Excluding null Value from Top 5 Rank but Including in Total

So this is a one I have been cracking my head because I know there has to be a way. I have a Top 10 Country column ranked based on sales. Unfortunately in my da

Pandas get topmost n records within each group

Suppose I have pandas DataFrame like this: df = pd.DataFrame({'id':[1,1,1,2,2,2,2,3,4],'value':[1,2,3,1,2,3,4,1,1]}) which looks like: id value 0 1