Hi I did groupby and nlargest on a dataframe. The result is a series, is there anyway to keep the result as a dataframe ?
ID NO
0 10
0 20
0 30
1 20
1 30
1 40
2 30
3 40
My code
TOP2 = df.groupby('ID')['NO'].nlargest(2)
.
It returns correct result, but I would like it to be a dataframe, not series.