Filter Events
Filters individual event rows from the eventstream. Exactly one of by_column, func, or sql must be provided.
Usage
# Keep only specific events
es.filter_events(by_column={"column": "event", "values": ["login", "purchase"]})
# Exclude specific events
es.filter_events(by_column={"column": "event", "values": ["error"], "exclude": True})
# Filter using a Python function
es.filter_events(func=lambda df: df["revenue"] > 0)
# Filter using SQL
es.filter_events(sql="SELECT * FROM eventstream WHERE event != 'bot_visit'")Parameters
| Parameter | Type | Description |
|---|---|---|
by_column | dict | None | Dict with keys: column (str), values (list), and optional exclude (bool, default False). When exclude is True, matching rows are removed instead of kept. |
func | Callable | None | A function (df) → bool_mask returning a boolean Series. |
sql | str | None | A DuckDB SQL query selecting from eventstream. Must return the same columns as the input. |