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
| Parameter | Type | Description |
|---|---|---|
ast_condition | dict | A nested condition tree. See below. |
path_id_col | str | None | Override the path ID column. |
event_col | str | None | Override 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
| Op | Structure |
|---|---|
and | {"op": "and", "args": [...]} |
or | {"op": "or", "args": [...]} |
not | {"op": "not", "args": [...]} |
Comparison operators
=, !=, >, <, >=, <=, in
Available metrics
| Metric | metric_args | Description |
|---|---|---|
length | — | Number of events in the path. |
duration | — | Total path duration in seconds. |
has | events: str or list | Whether the path contains the event(s). |
event_count | event: str or list | Number of times an event occurred. |
time_between | event_from, event_to | Seconds between first occurrences of two events. |
active_days | — | Number of distinct calendar days with activity. |
matches | pattern: str | Whether the path matches a sequence pattern. |