Filter Events
Keep only rows that match a column filter, a Python predicate, or a SQL query.
Exactly one of keep, drop, func, or sql must be provided. If all are
None the eventstream is returned unchanged.
Usage
stream.filter_events(keep={"event": ["purchase", "add_to_cart"]})
stream.filter_events(drop={"event": ["system_event"], "platform": ["bot"]})
stream.filter_events(sql="SELECT * FROM eventstream WHERE event NOT LIKE 'system_%'")
Parameters
| Parameter | Type | Description |
|---|---|---|
keep | dict, optional | {column: values} mapping. Keeps rows where each listed column contains one of the listed values. Multiple columns combine with AND: a row is kept only if it matches every entry. Example: {"event": ["purchase", "add_to_cart"]}. |
drop | dict, optional | Same {column: values} format, but removes the matching rows instead. Multiple columns combine with OR: a row is removed if it matches any entry (the exact complement of keep). |
func | callable, optional | A function that accepts the raw pandas DataFrame and returns a boolean Series. Rows where the Series is True are kept. |
sql | str, optional | DuckDB SQL SELECT statement that reads from the eventstream table alias and returns all original columns. Example: "SELECT * FROM eventstream WHERE event NOT LIKE 'system_%'". |