pandas_paddles.paddles.build_filter#
- pandas_paddles.paddles.build_filter(predicates, op=<built-in function and_>)[source]#
Build a filter expression from column-value pairs
- ::
df.loc[build_filter({“a”: “A”, “b”: “B”})
is equivalent to:
df.loc[ (DF["a"] == "A") & (DF["b"] == "B") ]
- Parameters
predicates (Dict[Union[str, pandas_paddles.pandas.PandasDataframeContext], Any]) –
The column-value pairs to filter on.
Columns can be either specified as
stror asDF-expressions.Values can be literal values or
DF-expressions.op (Union[Callable[[Any, Any], Any], Literal['and'], typing.Literal['&'], typing.Literal['or'], typing.Literal['|']]) – The operator to combine the predicates.
operator.and_()andoperator.or_()will be most useful."and","&"and"or","|"are also accepted and the respective operator is used.
- Returns
The
DF-expression combining the predicates.- Return type
PandasDataframeContext