filter

pydiverse.transform.filter(*predicates: ColExpr[Bool]) Pipeable[source]

Selects a subset of rows based on some condition.

Parameters:

predicates – Column expressions of boolean type to filter by. Only rows where all expressions are true are included in the result.

Examples

>>> t = pdt.Table({"a": [3, 2, 6, 4], "b": ["lll", "g", "u0", "__**_"]})
>>> t >> filter(t.a <= 4, ~t.b.str.contains("_")) >> show()
shape: (2, 2)
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ i64 ┆ str │
╞═════╪═════╡
│ 3   ┆ lll │
│ 2   ┆ g   │
└─────┴─────┘