Sort crm by customer_id and updated_at. A plan change is a row whose plan differs from the same customer's previous row (a customer's first row is not a change).
Store the number of plan changes per customer in result (a Series indexed by customer_id, every customer included).
import pandas as pd
crm = pd.DataFrame({
"customer_id": ["C1", "C2", "C1", "C3", "C2", "C1", "C4"],
"city": ["Pune", "Delhi", "Mumbai", "Jaipur", "Delhi", "Mumbai", "Pune"],
"plan": ["Basic", "Gold", "Silver", "Basic", "Silver", "Gold", "Basic"],
"updated_at": pd.to_datetime(["2025-01-10", "2025-01-15", "2025-03-02", "2025-02-11", "2025-04-20", "2025-05-05", "2025-03-30"]),
})Store your final answer in a variable named result.
Each hint gives a little more help. Try on your own first.
Run your code to see the output here.