A session is a period of a user's interaction with applications, represented by related event records. Event data links sessions to users, applications, event types, and timestamps. section 12.5.1
Analyze sessions by progressively checking and transforming event data:
- Inspect missing values, data types, event categories, users, applications, and date ranges before calculating metrics. section 12.5.1
- Count distinct sessions per user and inspect their distribution to identify users with unusually many sessions. section 12.5.1
- Group records by user and session, then use the earliest and latest timestamps to calculate session duration. section 12.5.1
Calculating session duration
Group cleaned event records by user_id and session_id. Define each session's start as its minimum timestamp and its end as its maximum timestamp, then calculate duration in minutes. section 12.5.1
sessions_per_user = (
app_data
.groupby("user_id")
["session_id"]
.nunique()
)
sessions_per_user.describe()
Inspect the pandas calculation of distinct sessions per user. section 12.5.1
