Bucketize

class nvtabular.ops.Bucketize(boundaries)[source]

Bases: nvtabular.ops.operator.Operator

This operation transforms continuous features into categorical features with bins based on the provided bin boundaries.

Example usage:

#
cont_names = ['cont1', 'cont2']
boundaries = {
    'cont1': [-50, 0, 50],
    'cont2': [0, 25, 50, 75, 100]
}
bucketize_op = cont_names >> ops.Bucketize(boundaries)
processor = nvt.Workflow(bucketize_op)
Parameters

boundaries (int, dict or callable) – Defines how to transform the continuous values into bins

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

property output_tags
property output_dtype