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 str or as DF-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_() and operator.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