You can chain it with
df.max which takes
level as parameter. At level 0 it takes max from every
Here, you will index as
Customer_ID only to get both
Col2_ID as index try this.
out = df.groupby(["Customer_ID", "Col2_ID"]).Qta.sum().reset_index(level=1) idx = out['Qta'].max(level=0).index out.loc[idx].set_index('Col2_ID', append=True)
Now, here index of
CLICK HERE to find out more related problems solutions.