Truncate Paths
Trim each path to the window between two anchor events (inclusive).
For each path, the first occurrence of start_event and the first occurrence
of end_event that comes after it are found. Events outside this window are
dropped. Paths that do not contain both anchors in the correct order are
removed entirely.
Use start_event="path_start" / end_event="path_end" to refer to the actual
first and last events of the path.
Usage
stream.truncate_paths(start_event="registration", end_event="purchase")
stream.truncate_paths(start_event="registration", end_event="path_end")
How it works
For each path, truncate_paths finds the first start_event and the first
end_event after it, and keeps only the window between them, both anchors
included. A path missing either anchor — or containing them in the wrong order
— is dropped entirely, so the output holds only paths that actually made the
journey you asked about.
Before — three paths, only one of which registers and then buys:
- u1:
home → registration → browse → purchase → logout - u2:
home → browse → purchase(never registered) - u3:
home → registration → browse(never purchased)
stream.truncate_paths(start_event="registration", end_event="purchase")
After — u1 is trimmed to the window; u2 and u3 are gone:
- u1:
registration → browse → purchase
That "dropped entirely" behaviour is the point: the result is a clean population of converting paths, ready for a Transition Graph or Step Sankey that answers "how do users who did convert get there?"
Use path_start / path_end to anchor on the real ends of a path — for
example, everything a user did before their first purchase:
stream.truncate_paths(start_event="path_start", end_event="purchase")
Parameters
| Parameter | Type | Description |
|---|---|---|
start_event | str | Name of the event that marks the start of the window. |
end_event | str | Name of the event that marks the end of the window. |
path_col | str, optional | Path ID column override; defaults to schema.path_col. |
event_col | str, optional | Event column override; defaults to schema.event_col. |