A product analyst wants to split each user's activity into sessions. Within a user's stream of events (ordered by ts, a timestamp in minutes), a new session begins whenever the gap from the previous event exceeds 30 minutes — strictly greater than 30, so a gap of exactly 30 stays in the same session. The first event for each user always starts session 1.
events
Your task: return user_id, ts, and session — a 1-based session number per user, increasing by one each time a gap over 30 minutes opens a new session.
Assign your answer DataFrame to result. Row order doesn't matter.