0

I have a data frame like this:

df = pd.DataFrame({'cid': [1, 3, 5, 1, 3, 5],
                  'spending': [100, 30, 80, 200, 70, 900],
                  'month': [1, 2, 8, 3, 1, 6]})

cid = customer_id

  • I need, most_spending_month: the month that each customer has the most spending
  • I need the month in which the customer spends maximum(spending) The output I want is like this:

enter image description here

How do I get this output?

0 Answers0