SpinTheMic
Pro

Interview practice question

Sessionising event data in pandas

Data Analyst · Python and Pandas · Intermediate

How would you assign session IDs to user events in pandas using a 30-minute inactivity rule?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • Sort by user and timestamp.
  • groupby user, diff timestamps.
  • New session where gap > 30 min or NaN.
  • cumsum of new-session flag per user.
  • Combine user + session number.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics