nlargest hierarchy series pandas

Solutions on MaxInterview for nlargest hierarchy series pandas by the best coders in the world

showing results for - "nlargest hierarchy series pandas"
Vanessa
20 Aug 2019
1print (grouped.groupby(level='yearmonth').nlargest(3).reset_index(level=0, drop=True))
2yearmonth  product
3201601     E          180
4           A          100
5           B           90
6201602     F          220
7           A          200
8           C          120
9201603     B          120
10           C          110
11           D          110
12Name: val, dtype: int64