Web analytics groups each user's events into sessions: a new session starts when the gap since that user's previous event is more than timeout seconds (Google Analytics uses 30 minutes).
events has columns user and ts (integer seconds), in any order. Implement:
sessionize(events, timeout=1800): return a copy with a session_id column formatted f"{user}-{k}", where k counts that user's sessions from 1 in time order. Keep the original row order and index.session_summary(events, timeout=1800): one row per session with columns session_id, user, start, end, n_events and duration (end − start), sorted by user then start, with a fresh index