Filter Paths

Filters entire paths based on computed path-level metrics. Paths that do not match the condition are removed entirely (all their events are dropped). Unlike Filter Events, this operates at the path level.

Usage

# Keep paths with more than 5 events
es.filter_paths({"op": ">", "metric": "length", "value": 5})

# Keep paths that contain a purchase
es.filter_paths({"op": "=", "metric": "has", "metric_args": {"events": "purchase"}, "value": True})

# Combine conditions
es.filter_paths({
    "op": "and",
    "args": [
        {"op": ">", "metric": "length", "value": 3},
        {"op": "<", "metric": "duration", "value": 3600},
    ]
})

Parameters

ParameterTypeDescription
ast_conditiondictA nested condition tree. See below.
path_id_colstr | NoneOverride the path ID column.
event_colstr | NoneOverride the event column.

Condition tree

The ast_condition is a nested dict. Leaf nodes compare a metric against a value. Internal nodes combine leaves with logical operators. See Path Metrics for the full list of available metrics and their arguments.

Logical operators

OpStructure
and{"op": "and", "args": [...]}
or{"op": "or", "args": [...]}
not{"op": "not", "args": [...]}

Comparison operators

=, !=, >, <, >=, <=, in

Available metrics

Metricmetric_argsDescription
lengthNumber of events in the path.
durationTotal path duration in seconds.
hasevents: str or listWhether the path contains the event(s).
event_countevent: str or listNumber of times an event occurred.
time_betweenevent_from, event_toSeconds between first occurrences of two events.
active_daysNumber of distinct calendar days with activity.
matchespattern: strWhether the path matches a sequence pattern.