Filtering
The filter statement keeps rows that match a condition. Rows that do not match are dropped.
Comparison operators
| Operator | Meaning |
|---|---|
== |
Equal |
!= |
Not equal |
> |
Greater than |
< |
Less than |
>= |
Greater than or equal |
<= |
Less than or equal |
filter price > 100
filter quantity != 0
filter status == "active"
filter score >= 0.9
filter discount <= 0.5
Logical operators
Combine conditions with and / or:
filter amount > 1000 and category == "premium"
filter status == "active" or price > 500
filter region == "North" and status == "active" and amount > 100
Note
and binds more tightly than or. Use parentheses if you need explicit grouping — though in practice most filters are simple enough that this doesn't arise.
Membership — in / not in
Test whether a value is in a list:
Use a Python variable for the list:
Range — between
Test whether a value falls within an inclusive range:
String matching
| Operator | Meaning |
|---|---|
contains "x" |
String contains substring |
not contains "x" |
String does not contain substring |
startswith "x" |
String starts with prefix |
endswith "x" |
String ends with suffix |
filter product contains "Laptop"
filter name not contains "test"
filter event startswith "login"
filter filename endswith ".csv"
Python variable references
Any filter value can be a Python variable, prefixed with ::
Multiple filter lines
Multiple filter lines under the same with block are applied in sequence (AND logic):