Result Types¶
Explore on DeepWiki
Ask questions about result structures, DataFrame conversion, or type usage patterns.
All result types are immutable frozen dataclasses with:
- Lazy DataFrame conversion via the
.dfproperty - JSON serialization via the
.to_dict()method - Full type hints for IDE/mypy support
Fetch Results¶
mixpanel_data.FetchResult
dataclass
¶
FetchResult(
table: str,
rows: int,
type: Literal["events", "profiles"],
duration_seconds: float,
date_range: tuple[str, str] | None,
fetched_at: datetime,
_data: list[dict[str, Any]] = list(),
_df_cache: DataFrame | None = None,
)
Result of a data fetch operation.
Represents the outcome of fetching events or profiles from Mixpanel and storing them in the local database.
date_range
instance-attribute
¶
Date range for events (None for profiles).
df
property
¶
Convert result data to pandas DataFrame.
Conversion is lazy - computed on first access and cached.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with fetched data. |
to_dict
¶
Serialize result for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary representation (excludes raw data). |
dict[str, Any]
|
datetime values are converted to ISO format strings. |
Source code in src/mixpanel_data/types.py
Parallel Fetch Types¶
Types for parallel event fetching with progress tracking and failure handling.
mixpanel_data.ParallelFetchResult
dataclass
¶
ParallelFetchResult(
table: str,
total_rows: int,
successful_batches: int,
failed_batches: int,
failed_date_ranges: tuple[tuple[str, str], ...],
duration_seconds: float,
fetched_at: datetime,
)
Result of a parallel fetch operation.
Aggregates results from all batches, providing summary statistics and information about any failures for retry.
| ATTRIBUTE | DESCRIPTION |
|---|---|
table |
Name of the created/appended table.
TYPE:
|
total_rows |
Total number of rows fetched across all batches.
TYPE:
|
successful_batches |
Number of batches that completed successfully.
TYPE:
|
failed_batches |
Number of batches that failed.
TYPE:
|
failed_date_ranges |
Date ranges (from_date, to_date) of failed batches.
TYPE:
|
duration_seconds |
Total time taken for the parallel fetch.
TYPE:
|
fetched_at |
Timestamp when fetch completed.
TYPE:
|
Example
successful_batches
instance-attribute
¶
Number of batches that completed successfully.
failed_date_ranges
instance-attribute
¶
Date ranges (from_date, to_date) of failed batches for retry.
duration_seconds
instance-attribute
¶
Total time taken for the parallel fetch.
has_failures
property
¶
Check if any batches failed.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if at least one batch failed, False otherwise. |
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all result fields including has_failures. |
Source code in src/mixpanel_data/types.py
mixpanel_data.BatchProgress
dataclass
¶
BatchProgress(
from_date: str,
to_date: str,
batch_index: int,
total_batches: int,
rows: int,
success: bool,
error: str | None = None,
)
Progress update for a parallel fetch batch.
Sent to the on_batch_complete callback when a batch finishes (successfully or with error).
| ATTRIBUTE | DESCRIPTION |
|---|---|
from_date |
Start date of this batch (YYYY-MM-DD).
TYPE:
|
to_date |
End date of this batch (YYYY-MM-DD).
TYPE:
|
batch_index |
Zero-based index of this batch.
TYPE:
|
total_batches |
Total number of batches in the parallel fetch.
TYPE:
|
rows |
Number of rows fetched in this batch (0 if failed).
TYPE:
|
success |
Whether this batch completed successfully.
TYPE:
|
error |
Error message if failed, None if successful.
TYPE:
|
Example
total_batches
instance-attribute
¶
Total number of batches in the parallel fetch.
error
class-attribute
instance-attribute
¶
Error message if failed, None if successful.
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all batch progress fields. |
Source code in src/mixpanel_data/types.py
mixpanel_data.BatchResult
dataclass
¶
Result of fetching a single date range chunk.
Internal type used by ParallelFetcherService to track batch outcomes. Contains either the fetched data (on success) or error info (on failure).
| ATTRIBUTE | DESCRIPTION |
|---|---|
from_date |
Start date of this batch (YYYY-MM-DD).
TYPE:
|
to_date |
End date of this batch (YYYY-MM-DD).
TYPE:
|
rows |
Number of rows fetched (0 if failed).
TYPE:
|
success |
Whether the batch completed successfully.
TYPE:
|
error |
Exception message if failed, None if successful.
TYPE:
|
Note
Data is not included in to_dict() as it's consumed by the writer thread and is not JSON-serializable (iterator of dicts).
Parallel Profile Fetch Types¶
Types for parallel profile fetching with page-based progress tracking.
mixpanel_data.ParallelProfileResult
dataclass
¶
ParallelProfileResult(
table: str,
total_rows: int,
successful_pages: int,
failed_pages: int,
failed_page_indices: tuple[int, ...],
duration_seconds: float,
fetched_at: datetime,
)
Result of a parallel profile fetch operation.
Aggregates results from all pages, providing summary statistics and information about any failures for retry.
| ATTRIBUTE | DESCRIPTION |
|---|---|
table |
Name of the created/appended table.
TYPE:
|
total_rows |
Total number of rows fetched across all pages.
TYPE:
|
successful_pages |
Number of pages that completed successfully.
TYPE:
|
failed_pages |
Number of pages that failed.
TYPE:
|
failed_page_indices |
Page indices of failed pages for retry.
TYPE:
|
duration_seconds |
Total time taken for the parallel fetch.
TYPE:
|
fetched_at |
Timestamp when fetch completed.
TYPE:
|
Example
successful_pages
instance-attribute
¶
Number of pages that completed successfully.
failed_page_indices
instance-attribute
¶
Page indices of failed pages for retry.
duration_seconds
instance-attribute
¶
Total time taken for the parallel fetch.
has_failures
property
¶
Check if any pages failed.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if at least one page failed, False otherwise. |
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all result fields including has_failures. |
Source code in src/mixpanel_data/types.py
mixpanel_data.ProfileProgress
dataclass
¶
ProfileProgress(
page_index: int,
total_pages: int | None,
rows: int,
success: bool,
error: str | None,
cumulative_rows: int,
)
Progress update for a parallel profile fetch page.
Sent to the on_page_complete callback when a page finishes (successfully or with error). Used for progress visibility during parallel profile fetching operations.
| ATTRIBUTE | DESCRIPTION |
|---|---|
page_index |
Zero-based index of this page.
TYPE:
|
total_pages |
Total pages if known, None if not yet determined.
TYPE:
|
rows |
Number of rows fetched in this page (0 if failed).
TYPE:
|
success |
Whether this page completed successfully.
TYPE:
|
error |
Error message if failed, None if successful.
TYPE:
|
cumulative_rows |
Total rows fetched so far across all pages.
TYPE:
|
Example
def on_page(progress: ProfileProgress) -> None:
status = "✓" if progress.success else "✗"
pct = f"{progress.page_index + 1}/{progress.total_pages}" if progress.total_pages else f"{progress.page_index + 1}/?"
print(f"[{status}] Page {pct}: {progress.cumulative_rows} total rows")
result = ws.fetch_profiles(
name="users",
parallel=True,
on_page_complete=on_page,
)
total_pages
instance-attribute
¶
Total pages if known, None if not yet determined.
cumulative_rows
instance-attribute
¶
Total rows fetched so far across all pages.
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all profile progress fields. |
Source code in src/mixpanel_data/types.py
mixpanel_data.ProfilePageResult
dataclass
¶
ProfilePageResult(
profiles: list[dict[str, Any]],
session_id: str | None,
page: int,
has_more: bool,
total: int,
page_size: int,
)
Result from fetching a single page of profiles.
Contains the profiles from one page of the Engage API along with pagination metadata for fetching subsequent pages.
| ATTRIBUTE | DESCRIPTION |
|---|---|
profiles |
List of profile dictionaries from this page.
TYPE:
|
session_id |
Session ID for fetching next page, None if no more pages.
TYPE:
|
page |
Zero-based page index that was fetched.
TYPE:
|
has_more |
True if there are more pages to fetch.
TYPE:
|
total |
Total number of profiles matching the query across all pages.
TYPE:
|
page_size |
Number of profiles per page (typically 1000).
TYPE:
|
Example
# Fetch first page to get pagination metadata
result = api_client.export_profiles_page(page=0)
all_profiles = list(result.profiles)
# Pre-compute total pages for parallel fetching
total_pages = result.num_pages
print(f"Fetching {total_pages} pages ({result.total} profiles)")
# Continue fetching if more pages
while result.has_more:
result = api_client.export_profiles_page(
page=result.page + 1,
session_id=result.session_id,
)
all_profiles.extend(result.profiles)
profiles
instance-attribute
¶
List of profile dictionaries from this page.
session_id
instance-attribute
¶
Session ID for fetching next page, None if no more pages.
num_pages
property
¶
Calculate total number of pages needed.
Uses ceiling division to ensure partial pages are counted.
| RETURNS | DESCRIPTION |
|---|---|
int
|
Total pages needed to fetch all profiles. |
int
|
Returns 0 if total is 0 (empty result set). |
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all page result fields including pagination metadata. |
Source code in src/mixpanel_data/types.py
Query Results¶
mixpanel_data.SegmentationResult
dataclass
¶
SegmentationResult(
event: str,
from_date: str,
to_date: str,
unit: Literal["day", "week", "month"],
segment_property: str | None,
total: int,
series: dict[str, dict[str, int]] = dict(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Result of a segmentation query.
Contains time-series data for an event, optionally segmented by a property.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
segment_property
instance-attribute
¶
Property used for segmentation (None if total only).
series
class-attribute
instance-attribute
¶
Time series data by segment.
Structure: {segment_name: {date_string: count}} Example: {"US": {"2024-01-01": 150, "2024-01-02": 200}, "EU": {...}} For unsegmented queries, segment_name is "total".
df
property
¶
Convert to DataFrame with columns: date, segment, count.
For unsegmented queries, segment column is 'total'.
to_dict
¶
Serialize for JSON output.
Source code in src/mixpanel_data/types.py
mixpanel_data.FunnelResult
dataclass
¶
FunnelResult(
funnel_id: int,
funnel_name: str,
from_date: str,
to_date: str,
conversion_rate: float,
steps: list[FunnelStep] = list(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Result of a funnel query.
Contains step-by-step conversion data for a funnel.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
mixpanel_data.FunnelStep
dataclass
¶
Single step in a funnel.
conversion_rate
instance-attribute
¶
Conversion rate from previous step (0.0 to 1.0).
mixpanel_data.RetentionResult
dataclass
¶
RetentionResult(
born_event: str,
return_event: str,
from_date: str,
to_date: str,
unit: Literal["day", "week", "month"],
cohorts: list[CohortInfo] = list(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Result of a retention query.
Contains cohort-based retention data.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
mixpanel_data.CohortInfo
dataclass
¶
Retention data for a single cohort.
retention
class-attribute
instance-attribute
¶
Retention percentages by period (0.0 to 1.0).
mixpanel_data.JQLResult
dataclass
¶
Bases: ResultWithDataFrame
Result of a JQL query.
JQL (JavaScript Query Language) allows custom queries against Mixpanel data.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
The df property intelligently detects JQL result patterns (groupBy, percentiles, simple dicts) and converts them to clean tabular format.
df
property
¶
Convert result to DataFrame with intelligent structure detection.
The conversion strategy depends on the detected JQL result pattern:
groupBy results (detected by {key: [...], value: X} structure): - Keys expanded to columns: key_0, key_1, key_2, ... - Single value: "value" column - Multiple reducers (value array): value_0, value_1, value_2, ... - Additional fields (from .map()): preserved as-is - Example: {"key": ["US"], "value": 100, "name": "USA"} -> columns: key_0, value, name
Nested percentile results ([[{percentile: X, value: Y}, ...]]): - Outer list unwrapped, inner dicts converted directly
Simple list of dicts (already well-structured): - Converted directly to DataFrame preserving all fields
Fallback for other structures (scalars, mixed types, incompatible dicts): - Safely wrapped in single "value" column to prevent data loss - Used when structure doesn't match known patterns
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If groupBy structure has inconsistent value types across rows (some scalar, some array) which indicates malformed query results. |
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame representation, cached after first access. |
Discovery Types¶
mixpanel_data.FunnelInfo
dataclass
¶
A saved funnel definition.
Represents a funnel saved in Mixpanel that can be queried using the funnel() method.
mixpanel_data.SavedCohort
dataclass
¶
A saved cohort definition.
Represents a user cohort saved in Mixpanel for profile filtering.
to_dict
¶
Serialize for JSON output.
Source code in src/mixpanel_data/types.py
mixpanel_data.TopEvent
dataclass
¶
Today's event activity data.
Represents an event's current activity including count and trend.
Lexicon Types¶
mixpanel_data.LexiconSchema
dataclass
¶
Complete schema definition from Mixpanel Lexicon.
Represents a documented event or profile property definition from the Mixpanel data dictionary.
mixpanel_data.LexiconDefinition
dataclass
¶
LexiconDefinition(
description: str | None,
properties: dict[str, LexiconProperty],
metadata: LexiconMetadata | None,
)
Full schema definition for an event or profile property in Lexicon.
Contains the structural definition including description, properties, and platform-specific metadata.
properties
instance-attribute
¶
Property definitions keyed by property name.
metadata
instance-attribute
¶
Optional Mixpanel-specific metadata for the entity.
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with properties, and optionally description and metadata. |
Source code in src/mixpanel_data/types.py
mixpanel_data.LexiconProperty
dataclass
¶
Schema definition for a single property in a Lexicon schema.
Describes the type and metadata for an event or profile property.
type
instance-attribute
¶
JSON Schema type (string, number, boolean, array, object, integer, null).
description
instance-attribute
¶
Human-readable description of the property.
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with type, and optionally description and metadata. |
Source code in src/mixpanel_data/types.py
mixpanel_data.LexiconMetadata
dataclass
¶
LexiconMetadata(
source: str | None,
display_name: str | None,
tags: list[str],
hidden: bool,
dropped: bool,
contacts: list[str],
team_contacts: list[str],
)
Mixpanel-specific metadata for Lexicon schemas and properties.
Contains platform-specific information about how schemas and properties are displayed and organized in the Mixpanel UI.
source
instance-attribute
¶
Origin of the schema definition (e.g., 'api', 'csv', 'ui').
display_name
instance-attribute
¶
Human-readable display name in Mixpanel UI.
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all metadata fields. |
Source code in src/mixpanel_data/types.py
Event Analytics Results¶
mixpanel_data.EventCountsResult
dataclass
¶
EventCountsResult(
events: list[str],
from_date: str,
to_date: str,
unit: Literal["day", "week", "month"],
type: Literal["general", "unique", "average"],
series: dict[str, dict[str, int]],
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Time-series event count data.
Contains aggregate counts for multiple events over time with lazy DataFrame conversion support.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
mixpanel_data.PropertyCountsResult
dataclass
¶
PropertyCountsResult(
event: str,
property_name: str,
from_date: str,
to_date: str,
unit: Literal["day", "week", "month"],
type: Literal["general", "unique", "average"],
series: dict[str, dict[str, int]],
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Time-series property value distribution data.
Contains aggregate counts by property values over time with lazy DataFrame conversion support.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
series
instance-attribute
¶
Time series data by property value.
Structure: {property_value: {date: count}} Example: {"US": {"2024-01-01": 150, "2024-01-02": 200}, "EU": {...}}
df
property
¶
Convert to DataFrame with columns: date, value, count.
Conversion is lazy - computed on first access and cached.
to_dict
¶
Serialize for JSON output.
Source code in src/mixpanel_data/types.py
Advanced Query Results¶
mixpanel_data.UserEvent
dataclass
¶
mixpanel_data.ActivityFeedResult
dataclass
¶
ActivityFeedResult(
distinct_ids: list[str],
from_date: str | None,
to_date: str | None,
events: list[UserEvent] = list(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Collection of user events from activity feed query.
Contains chronological event history for one or more users with lazy DataFrame conversion support.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
from_date
instance-attribute
¶
Start date filter (YYYY-MM-DD), None if not specified.
to_date
instance-attribute
¶
End date filter (YYYY-MM-DD), None if not specified.
events
class-attribute
instance-attribute
¶
Event history (chronological order).
df
property
¶
Convert to DataFrame with columns: event, time, distinct_id, + properties.
Flattens event properties into individual columns. Conversion is lazy - computed on first access and cached.
to_dict
¶
Serialize for JSON output.
Source code in src/mixpanel_data/types.py
mixpanel_data.FrequencyResult
dataclass
¶
FrequencyResult(
event: str | None,
from_date: str,
to_date: str,
unit: Literal["day", "week", "month"],
addiction_unit: Literal["hour", "day"],
data: dict[str, list[int]] = dict(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Event frequency distribution (addiction analysis).
Contains frequency arrays showing how many users performed events in N time periods, with lazy DataFrame conversion support.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
data
class-attribute
instance-attribute
¶
Frequency arrays by date.
Structure: {date: [count_1, count_2, ...]} Example: {"2024-01-01": [100, 50, 25, 10]}
Each array shows user counts by frequency: - Index 0: users active exactly 1 time - Index 1: users active exactly 2 times - Index N: users active exactly N+1 times
df
property
¶
Convert to DataFrame with columns: date, period_1, period_2, ...
Each period_N column shows users active in at least N time periods. Conversion is lazy - computed on first access and cached.
to_dict
¶
Serialize for JSON output.
Source code in src/mixpanel_data/types.py
mixpanel_data.NumericBucketResult
dataclass
¶
NumericBucketResult(
event: str,
from_date: str,
to_date: str,
property_expr: str,
unit: Literal["hour", "day"],
series: dict[str, dict[str, int]] = dict(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Events segmented into numeric property ranges.
Contains time-series data bucketed by automatically determined numeric ranges, with lazy DataFrame conversion support.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
mixpanel_data.NumericSumResult
dataclass
¶
NumericSumResult(
event: str,
from_date: str,
to_date: str,
property_expr: str,
unit: Literal["hour", "day"],
results: dict[str, float] = dict(),
computed_at: str | None = None,
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Sum of numeric property values per time unit.
Contains daily or hourly sum totals for a numeric property with lazy DataFrame conversion support.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
results
class-attribute
instance-attribute
¶
Sum values: {date: sum}.
computed_at
class-attribute
instance-attribute
¶
Computation timestamp (if provided by API).
df
property
¶
Convert to DataFrame with columns: date, sum.
Conversion is lazy - computed on first access and cached.
to_dict
¶
Serialize for JSON output.
Source code in src/mixpanel_data/types.py
mixpanel_data.NumericAverageResult
dataclass
¶
NumericAverageResult(
event: str,
from_date: str,
to_date: str,
property_expr: str,
unit: Literal["hour", "day"],
results: dict[str, float] = dict(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Average of numeric property values per time unit.
Contains daily or hourly average values for a numeric property with lazy DataFrame conversion support.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
Bookmark Types¶
mixpanel_data.BookmarkInfo
dataclass
¶
BookmarkInfo(
id: int,
name: str,
type: BookmarkType,
project_id: int,
created: str,
modified: str,
workspace_id: int | None = None,
dashboard_id: int | None = None,
description: str | None = None,
creator_id: int | None = None,
creator_name: str | None = None,
)
Metadata for a saved report (bookmark) from the Mixpanel Bookmarks API.
Represents a saved Insights, Funnel, Retention, or Flows report that can be queried using query_saved_report() or query_flows().
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Unique bookmark identifier.
TYPE:
|
name |
User-defined report name.
TYPE:
|
type |
Report type (insights, funnels, retention, flows, launch-analysis).
TYPE:
|
project_id |
Parent Mixpanel project ID.
TYPE:
|
created |
Creation timestamp (ISO format).
TYPE:
|
modified |
Last modification timestamp (ISO format).
TYPE:
|
workspace_id |
Optional workspace ID if scoped to a workspace.
TYPE:
|
dashboard_id |
Optional parent dashboard ID if linked to a dashboard.
TYPE:
|
description |
Optional user-provided description.
TYPE:
|
creator_id |
Optional creator's user ID.
TYPE:
|
creator_name |
Optional creator's display name.
TYPE:
|
workspace_id
class-attribute
instance-attribute
¶
Workspace ID if scoped to a workspace.
dashboard_id
class-attribute
instance-attribute
¶
Parent dashboard ID if linked to a dashboard.
description
class-attribute
instance-attribute
¶
User-provided description.
creator_name
class-attribute
instance-attribute
¶
Creator's display name.
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all bookmark metadata fields. |
Source code in src/mixpanel_data/types.py
mixpanel_data.SavedReportResult
dataclass
¶
SavedReportResult(
bookmark_id: int,
computed_at: str,
from_date: str,
to_date: str,
headers: list[str] = list(),
series: dict[str, Any] = dict(),
_df_cache: DataFrame | None = None,
)
Data from a saved report (Insights, Retention, or Funnel).
Contains data from a pre-configured saved report with automatic report type detection and lazy DataFrame conversion support.
The report_type property automatically detects the report type based on headers: "$retention" indicates retention, "$funnel" indicates funnel, otherwise it's an insights report.
| ATTRIBUTE | DESCRIPTION |
|---|---|
bookmark_id |
Saved report identifier.
TYPE:
|
computed_at |
When report was computed (ISO format).
TYPE:
|
from_date |
Report start date.
TYPE:
|
to_date |
Report end date.
TYPE:
|
headers |
Report column headers (used for type detection).
TYPE:
|
series |
Report data (structure varies by report type).
TYPE:
|
headers
class-attribute
instance-attribute
¶
Report column headers (used for type detection).
series
class-attribute
instance-attribute
¶
Report data (structure varies by report type).
For Insights reports: {event_name: {date: count}} For Retention reports: {series_name: {date: {segment: {first, counts, rates}}}} For Funnel reports: {count: {...}, overall_conv_ratio: {...}, ...}
report_type
property
¶
Detect the report type from headers.
| RETURNS | DESCRIPTION |
|---|---|
SavedReportType
|
'retention' if headers contain '$retention', |
SavedReportType
|
'funnel' if headers contain '$funnel', |
SavedReportType
|
'insights' otherwise. |
df
property
¶
Convert to DataFrame.
For Insights reports: columns are date, event, count. For Retention/Funnel reports: flattens the nested structure.
Conversion is lazy - computed on first access and cached.
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all report fields including detected report_type. |
Source code in src/mixpanel_data/types.py
mixpanel_data.FlowsResult
dataclass
¶
FlowsResult(
bookmark_id: int,
computed_at: str,
steps: list[dict[str, Any]] = list(),
breakdowns: list[dict[str, Any]] = list(),
overall_conversion_rate: float = 0.0,
metadata: dict[str, Any] = dict(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Data from a saved Flows report.
Contains user path/navigation data from a pre-configured Flows report with lazy DataFrame conversion support.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
| ATTRIBUTE | DESCRIPTION |
|---|---|
bookmark_id |
Saved report identifier.
TYPE:
|
computed_at |
When report was computed (ISO format).
TYPE:
|
steps |
Flow step data with event sequences and counts.
TYPE:
|
breakdowns |
Path breakdown data showing user flow distribution.
TYPE:
|
overall_conversion_rate |
End-to-end conversion rate (0.0 to 1.0).
TYPE:
|
metadata |
Additional API metadata from the response.
TYPE:
|
steps
class-attribute
instance-attribute
¶
Flow step data with event sequences and counts.
breakdowns
class-attribute
instance-attribute
¶
Path breakdown data showing user flow distribution.
overall_conversion_rate
class-attribute
instance-attribute
¶
End-to-end conversion rate (0.0 to 1.0).
metadata
class-attribute
instance-attribute
¶
Additional API metadata from the response.
df
property
¶
Convert steps to DataFrame.
Returns DataFrame with columns derived from step data structure. Conversion is lazy - computed on first access and cached.
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all flows report fields. |
Source code in src/mixpanel_data/types.py
JQL Discovery Types¶
mixpanel_data.PropertyDistributionResult
dataclass
¶
PropertyDistributionResult(
event: str,
property_name: str,
from_date: str,
to_date: str,
total_count: int,
values: tuple[PropertyValueCount, ...],
_df_cache: DataFrame | None = None,
)
Distribution of values for a property from JQL analysis.
Contains the top N values for a property with their counts and percentages, enabling quick understanding of property value distribution without fetching all data locally.
| ATTRIBUTE | DESCRIPTION |
|---|---|
event |
The event type analyzed.
TYPE:
|
property_name |
The property name analyzed.
TYPE:
|
from_date |
Query start date (YYYY-MM-DD).
TYPE:
|
to_date |
Query end date (YYYY-MM-DD).
TYPE:
|
total_count |
Total number of events with this property defined.
TYPE:
|
values |
Top values with counts and percentages.
TYPE:
|
values
instance-attribute
¶
Top values with counts and percentages.
df
property
¶
Convert to DataFrame with columns: value, count, percentage.
Conversion is lazy - computed on first access and cached.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with value distribution data. |
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all distribution data. |
Source code in src/mixpanel_data/types.py
mixpanel_data.PropertyValueCount
dataclass
¶
A single value and its count from property distribution analysis.
Represents one row in a property value distribution, showing the value, its occurrence count, and percentage of total.
| ATTRIBUTE | DESCRIPTION |
|---|---|
value |
The property value (can be string, number, bool, or None).
TYPE:
|
count |
Number of occurrences of this value.
TYPE:
|
percentage |
Percentage of total events (0.0 to 100.0).
TYPE:
|
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with value, count, and percentage. |
Source code in src/mixpanel_data/types.py
mixpanel_data.NumericPropertySummaryResult
dataclass
¶
NumericPropertySummaryResult(
event: str,
property_name: str,
from_date: str,
to_date: str,
count: int,
min: float,
max: float,
sum: float,
avg: float,
stddev: float,
percentiles: dict[int, float],
)
Statistical summary of a numeric property from JQL analysis.
Contains min, max, sum, average, standard deviation, and percentiles for a numeric property, enabling understanding of value distributions without fetching all data locally.
| ATTRIBUTE | DESCRIPTION |
|---|---|
event |
The event type analyzed.
TYPE:
|
property_name |
The property name analyzed.
TYPE:
|
from_date |
Query start date (YYYY-MM-DD).
TYPE:
|
to_date |
Query end date (YYYY-MM-DD).
TYPE:
|
count |
Number of events with this property defined.
TYPE:
|
min |
Minimum value.
TYPE:
|
max |
Maximum value.
TYPE:
|
sum |
Sum of all values.
TYPE:
|
avg |
Average value.
TYPE:
|
stddev |
Standard deviation.
TYPE:
|
percentiles |
Percentile values keyed by percentile number.
TYPE:
|
percentiles
instance-attribute
¶
Percentile values keyed by percentile number (e.g., {50: 98.0}).
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all numeric summary data. |
Source code in src/mixpanel_data/types.py
mixpanel_data.DailyCountsResult
dataclass
¶
DailyCountsResult(
from_date: str,
to_date: str,
events: tuple[str, ...] | None,
counts: tuple[DailyCount, ...],
_df_cache: DataFrame | None = None,
)
Time-series event counts by day from JQL analysis.
Contains daily event counts for quick activity trend analysis without complex segmentation setup.
| ATTRIBUTE | DESCRIPTION |
|---|---|
from_date |
Query start date (YYYY-MM-DD).
TYPE:
|
to_date |
Query end date (YYYY-MM-DD).
TYPE:
|
events |
Event types included (None for all events).
TYPE:
|
counts |
Daily counts for each event.
TYPE:
|
events
instance-attribute
¶
Event types included (None for all events).
df
property
¶
Convert to DataFrame with columns: date, event, count.
Conversion is lazy - computed on first access and cached.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with daily counts data. |
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all daily counts data. |
Source code in src/mixpanel_data/types.py
mixpanel_data.DailyCount
dataclass
¶
Event count for a single date from daily counts analysis.
Represents one row in a daily counts result, showing date, event, and count.
| ATTRIBUTE | DESCRIPTION |
|---|---|
date |
Date string (YYYY-MM-DD).
TYPE:
|
event |
Event name.
TYPE:
|
count |
Number of occurrences on this date.
TYPE:
|
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with date, event, and count. |
mixpanel_data.EngagementDistributionResult
dataclass
¶
EngagementDistributionResult(
from_date: str,
to_date: str,
events: tuple[str, ...] | None,
total_users: int,
buckets: tuple[EngagementBucket, ...],
_df_cache: DataFrame | None = None,
)
User engagement distribution from JQL analysis.
Shows how many users performed N events, helping understand user engagement patterns without fetching all data locally.
| ATTRIBUTE | DESCRIPTION |
|---|---|
from_date |
Query start date (YYYY-MM-DD).
TYPE:
|
to_date |
Query end date (YYYY-MM-DD).
TYPE:
|
events |
Event types included (None for all events).
TYPE:
|
total_users |
Total number of distinct users.
TYPE:
|
buckets |
Engagement buckets with user counts.
TYPE:
|
events
instance-attribute
¶
Event types included (None for all events).
buckets
instance-attribute
¶
Engagement buckets with user counts.
df
property
¶
Convert to DataFrame with engagement bucket columns.
Conversion is lazy - computed on first access and cached.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with engagement distribution data. |
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all engagement distribution data. |
Source code in src/mixpanel_data/types.py
mixpanel_data.EngagementBucket
dataclass
¶
User count in an engagement bucket from engagement analysis.
Represents one bucket in a user engagement distribution, showing how many users performed events in a certain frequency range.
| ATTRIBUTE | DESCRIPTION |
|---|---|
bucket_min |
Minimum events in this bucket.
TYPE:
|
bucket_label |
Human-readable label (e.g., "1", "2-5", "100+").
TYPE:
|
user_count |
Number of users in this bucket.
TYPE:
|
percentage |
Percentage of total users (0.0 to 100.0).
TYPE:
|
mixpanel_data.PropertyCoverageResult
dataclass
¶
PropertyCoverageResult(
event: str,
from_date: str,
to_date: str,
total_events: int,
coverage: tuple[PropertyCoverage, ...],
_df_cache: DataFrame | None = None,
)
Property coverage analysis result from JQL.
Shows which properties are consistently populated vs sparse, helping understand data quality before writing queries.
| ATTRIBUTE | DESCRIPTION |
|---|---|
event |
The event type analyzed.
TYPE:
|
from_date |
Query start date (YYYY-MM-DD).
TYPE:
|
to_date |
Query end date (YYYY-MM-DD).
TYPE:
|
total_events |
Total number of events analyzed.
TYPE:
|
coverage |
Coverage statistics for each property.
TYPE:
|
coverage
instance-attribute
¶
Coverage statistics for each property.
df
property
¶
Convert to DataFrame with property coverage columns.
Conversion is lazy - computed on first access and cached.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with property coverage data. |
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all coverage data. |
Source code in src/mixpanel_data/types.py
mixpanel_data.PropertyCoverage
dataclass
¶
Coverage statistics for a single property from coverage analysis.
Shows how often a property is defined vs null for a given event type.
| ATTRIBUTE | DESCRIPTION |
|---|---|
property |
Property name.
TYPE:
|
defined_count |
Number of events with this property defined.
TYPE:
|
null_count |
Number of events with this property null/undefined.
TYPE:
|
coverage_percentage |
Percentage of events with property defined (0.0-100.0).
TYPE:
|
Introspection Types¶
mixpanel_data.ColumnSummary
dataclass
¶
ColumnSummary(
column_name: str,
column_type: str,
min: Any,
max: Any,
approx_unique: int,
avg: float | None,
std: float | None,
q25: Any,
q50: Any,
q75: Any,
count: int,
null_percentage: float,
)
Statistical summary of a single column from DuckDB's SUMMARIZE command.
Contains per-column statistics including min/max, quartiles, null percentage, and approximate distinct counts. Numeric columns include additional stats like average and standard deviation.
column_type
instance-attribute
¶
DuckDB data type (VARCHAR, TIMESTAMP, INTEGER, JSON, etc.).
approx_unique
instance-attribute
¶
Approximate count of distinct values (HyperLogLog).
null_percentage
instance-attribute
¶
Percentage of null values (0.0 to 100.0).
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all column statistics. |
Source code in src/mixpanel_data/types.py
mixpanel_data.SummaryResult
dataclass
¶
SummaryResult(
table: str,
row_count: int,
columns: list[ColumnSummary] = list(),
_df_cache: DataFrame | None = None,
)
Statistical summary of all columns in a table.
Contains row count and per-column statistics from DuckDB's SUMMARIZE command. Provides both structured access via the columns list and DataFrame conversion via the df property.
columns
class-attribute
instance-attribute
¶
Per-column statistics.
df
property
¶
Convert to DataFrame with one row per column.
Conversion is lazy - computed on first access and cached.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with column statistics. |
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with table name, row count, and column statistics. |
Source code in src/mixpanel_data/types.py
mixpanel_data.EventStats
dataclass
¶
EventStats(
event_name: str,
count: int,
unique_users: int,
first_seen: datetime,
last_seen: datetime,
pct_of_total: float,
)
Statistics for a single event type.
Contains count, unique users, date range, and percentage of total for a specific event in an events table.
unique_users
instance-attribute
¶
Count of distinct users who triggered this event.
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with event statistics (datetimes as ISO strings). |
Source code in src/mixpanel_data/types.py
mixpanel_data.EventBreakdownResult
dataclass
¶
EventBreakdownResult(
table: str,
total_events: int,
total_users: int,
date_range: tuple[datetime, datetime],
events: list[EventStats] = list(),
_df_cache: DataFrame | None = None,
)
Distribution of events in a table.
Contains aggregate statistics and per-event breakdown with counts, unique users, date ranges, and percentages.
date_range
instance-attribute
¶
(earliest, latest) event timestamps.
events
class-attribute
instance-attribute
¶
Per-event statistics, ordered by count descending.
df
property
¶
Convert to DataFrame with one row per event type.
Conversion is lazy - computed on first access and cached.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with event statistics. |
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with table info and event statistics. |
Source code in src/mixpanel_data/types.py
mixpanel_data.ColumnStatsResult
dataclass
¶
ColumnStatsResult(
table: str,
column: str,
dtype: str,
count: int,
null_count: int,
null_pct: float,
unique_count: int,
unique_pct: float,
top_values: list[tuple[Any, int]] = list(),
min: float | None = None,
max: float | None = None,
mean: float | None = None,
std: float | None = None,
_df_cache: DataFrame | None = None,
)
Deep statistical analysis of a single column.
Provides detailed statistics including null rates, cardinality, top values, and numeric statistics (for numeric columns). Supports JSON path expressions for analyzing properties.
unique_pct
instance-attribute
¶
Percentage of values that are unique (0.0 to 100.0).
top_values
class-attribute
instance-attribute
¶
Most frequent (value, count) pairs.
min
class-attribute
instance-attribute
¶
Minimum value (None for non-numeric).
max
class-attribute
instance-attribute
¶
Maximum value (None for non-numeric).
mean
class-attribute
instance-attribute
¶
Mean value (None for non-numeric).
std
class-attribute
instance-attribute
¶
Standard deviation (None for non-numeric).
df
property
¶
Convert top values to DataFrame with columns: value, count.
Conversion is lazy - computed on first access and cached.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with top values and their counts. |
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all column statistics. |
Source code in src/mixpanel_data/types.py
Storage Types¶
mixpanel_data.TableMetadata
dataclass
¶
TableMetadata(
type: Literal["events", "profiles"],
fetched_at: datetime,
from_date: str | None = None,
to_date: str | None = None,
filter_events: list[str] | None = None,
filter_where: str | None = None,
filter_cohort_id: str | None = None,
filter_output_properties: list[str] | None = None,
filter_group_id: str | None = None,
filter_behaviors: str | None = None,
)
Metadata for a data fetch operation.
This metadata is passed to table creation methods and stored in the database's internal _metadata table for tracking fetch operations.
from_date
class-attribute
instance-attribute
¶
Start date for events (YYYY-MM-DD), None for profiles.
to_date
class-attribute
instance-attribute
¶
End date for events (YYYY-MM-DD), None for profiles.
filter_events
class-attribute
instance-attribute
¶
Event names filtered (if applicable).
filter_where
class-attribute
instance-attribute
¶
WHERE clause filter (if applicable).
filter_cohort_id
class-attribute
instance-attribute
¶
Cohort ID filter for profiles (if applicable).
filter_output_properties
class-attribute
instance-attribute
¶
Property names to include in output (if applicable).
filter_group_id
class-attribute
instance-attribute
¶
Group ID for group profile queries (if applicable).
filter_behaviors
class-attribute
instance-attribute
¶
Serialized behaviors filter for behavioral profile queries (if applicable).
to_dict
¶
Serialize for JSON output.
Source code in src/mixpanel_data/types.py
mixpanel_data.TableInfo
dataclass
¶
Information about a table in the database.
Returned by list_tables() to provide summary information about available tables without retrieving full schemas.
to_dict
¶
mixpanel_data.ColumnInfo
dataclass
¶
mixpanel_data.TableSchema
dataclass
¶
Schema information for a table.
Returned by get_schema() to describe the structure of a table, including all column definitions.
mixpanel_data.WorkspaceInfo
dataclass
¶
WorkspaceInfo(
path: Path | None,
project_id: str,
region: str,
account: str | None,
tables: list[str],
size_mb: float,
created_at: datetime | None,
)
Information about a Workspace instance.
Returned by Workspace.info() to provide metadata about the workspace including database location, connection details, and table summary.
path
instance-attribute
¶
Database file path (None for ephemeral or in-memory workspaces).
account
instance-attribute
¶
Named account used (None if credentials from environment).
size_mb
instance-attribute
¶
Database file size in megabytes (0.0 for in-memory workspaces).
created_at
instance-attribute
¶
When database was created (None if unknown).
to_dict
¶
Serialize for JSON output.