Skip to content

ExitPoll

Use c3d_exitpoll() to fetch response count data for ExitPoll surveys in your project. Each row in the returned DataFrame represents one response option for one question in one survey version, making it easy to compute response distributions.

Function signature

c3d_exitpoll(
    project_id=None,
    hook=None,
    version=None,
    start_date=None,
    end_date=None,
    exclude_test=True,
    exclude_idle=True,
    output="polars",
    warn_empty=True,
)

Parameters

Parameter Type Default Description
project_id Integer from c3d_project() Cognitive3D project ID
hook String None Filter to a specific survey hook name
version Integer None Filter to a specific survey version number
start_date date / datetime / string / int None Start of the date range ("YYYY-MM-DD")
end_date date / datetime / string / int None End of the date range ("YYYY-MM-DD")
exclude_test Boolean True Filter out sessions tagged as test
exclude_idle Boolean True Filter out sessions tagged as junk or idle
output String "polars" "polars" (default) or "pandas"
warn_empty Boolean True Emit a UserWarning when 0 rows are returned

Note

Unlike other functions in this package, c3d_exitpoll() does not default to a 30-day window when no date range is provided. Omitting start_date and end_date returns all-time data.

Output Columns

Column Description
hook Survey hook name
version Survey version number
question_index Zero-based position of the question within the survey
question_title Text of the question
question_type Question type (see below)
value Raw response value
value_label Human-readable label for the response value
count Number of respondents who selected this option

One row is returned per response option per question per version. Skipped responses appear with value="skipped" and value_label="skipped".

Question types and value labels

Question Type Value Label
boolean "0" "False"
boolean "1" "True"
happysad "0" "Sad"
happysad "1" "Happy"
thumbs "0" "Down"
thumbs "1" "Up"
voice "0" "Responded"
multiple varies answer text from survey metadata
scale varies raw value (no mapping applied)

Examples

import cognitive3dpy as c3d

# All ExitPoll data, all time
polls = c3d.c3d_exitpoll()

# Filter to a specific hook
polls = c3d.c3d_exitpoll(hook="end_questions")

# Specific hook, specific version, with date filter
polls = c3d.c3d_exitpoll(
    hook="end_questions",
    version=3,
    start_date="2025-01-01",
)

# All data from a date range
polls = c3d.c3d_exitpoll(
    start_date="2025-01-01",
    end_date="2025-06-01",
)

Working with ExitPoll data

The long format of the output makes it easy to compute percentages and visualize distributions:

import polars as pl
import cognitive3dpy as c3d

polls = c3d.c3d_exitpoll(hook="end_questions")

# Compute response proportions per question
polls.with_columns(
    (pl.col("count") / pl.col("count").sum().over("question_title")).alias("pct")
).select("question_title", "value_label", "count", "pct")

# Filter to a single question
comfort = polls.filter(pl.col("question_title") == "How comfortable did you feel?")

intercom If you have a question or any feedback about our documentation please use the Intercom button (purple circle) in the lower right corner of any web page or join our Discord.