liveBook · Manning

Session

As explained in The Well-Grounded Data Analyst

A session is a period of a user's interaction with applications represented by related event records.

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

How The Well-Grounded Data Analyst covers it

How deep it goes
Defines sessions through grouped identifiers and timestamps, then stops short of broader behavioral interpretation.
Examples
Uses app-event records, sessions-per-user distributions, user-level outliers, and average session-length histograms.
What it assumes
Assumes event records contain user identifiers, session identifiers, and timestamps, while demonstrating data-quality checks from the start.
What you can do after
Apply via pandas to count sessions per user and calculate session durations from event timestamps.
How it connects
Connects sessions with users, application events, timestamps, data cleaning, duplicate records, and descriptive statistics.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Well-Grounded Data Analyst. The section links point to the parts of the book it draws on.