0

I have a dataset containing mobile numbers, shop names, and number of orders each mobile number purchased from that shop. Like this:

mobile shop_name orders
99457811 A 5
99457811 B 2
88745215 C 7
88745215 D 1

I want to maintain only shops with max orders for each mobile number. like this:

mobile shop_name orders
99457811 A 5
88745215 C 7

I tried:

df_max = df.groupby("mobile").agg("max")

but it also returns max values for shop_name too so mixes my dataframe like this which I do not want it:

mobile shop_name orders
99457811 B 5
88745215 D 7

Anyone could you please help me on this? Thanks

0 Answers0