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

ParameterTypeDescription
by_columndict | NoneDict with keys: column (str), values (list), and optional exclude (bool, default False). When exclude is True, matching rows are removed instead of kept.
funcCallable | NoneA function (df) → bool_mask returning a boolean Series.
sqlstr | NoneA DuckDB SQL query selecting from eventstream. Must return the same columns as the input.