Filter

class nvtabular.ops.Filter(f: Callable[[pandas.core.frame.DataFrame], Union[pandas.core.frame.DataFrame, pandas.core.series.Series]])[source]

Bases: nvtabular.ops.operator.Operator

Filters rows from the dataset. This works by taking a callable that accepts a dataframe, and returns a dataframe with unwanted rows filtered out.

For example to filter out all rows that have a negative value in the a column:

filtered = cont_names >> ops.Filter(f=lambda df: df["a"] >=0)
processor = nvtabular.Workflow(filtered)
Parameters

f (callable) – Defines a function that takes a dataframe as an argument, and returns a new dataframe with unwanted rows filtered out.

transform(col_selector: merlin.dag.selector.ColumnSelector, df: pandas.core.frame.DataFrame)pandas.core.frame.DataFrame[source]

Transform the dataframe by applying this operator to the set of input columns

Parameters
  • columns (list of str or list of list of str) – The columns to apply this operator to

  • df (Dataframe) – A pandas or cudf dataframe that this operator will work on

Returns

Returns a transformed dataframe for this operator

Return type

DataFrame