JoinExternal

class nvtabular.ops.JoinExternal(df_ext, on, how='left', on_ext=None, columns_ext=None, drop_duplicates_ext=None, kind_ext=None, cache='host', **kwargs)[source]

Bases: nvtabular.ops.operator.Operator

Join each dataset partition to an external table. For performance reasons, only “left” and “inner” join transformations are supported.

Example usage:

# Load dataset which should be joined to the main dataset
df_external = cudf.read_parquet('external.parquet')

# Use JoinExternal to define a NVTabular workflow
joined = ColumnSelector(columns_left) >> nvt.ops.JoinExternal(
    df_ext,
    on=['key1', 'key2'],
    on_ext=['key1_ext', 'key2_ext'],
    how='left',
    columns_ext=['key1_ext', 'key2_ext', 'cat1', 'cat2', 'num1'],
    kind_ext='cudf',
    cache='device'
) >> ...
processor = nvtabular.Workflow(joined)
Parameters
  • df_ext (DataFrame, pyarrow.Table, Dataset, dd.DataFrame, or file path(s)) – The external table to join to each partition of the dataset. Note that the join must be a partition-wise transformation. Therefore, if df_ext is a multi-partition Dask collection, it will need to be broadcasted to every partition.

  • on (str or list(str)) – Column name(s) to merge on

  • how ({"left", "inner"}; default "left") – Type of join operation to perform.

  • on_ext (str or list(str); Optional) – Column name(s) on external table to join on. By default, we assume on_ext is the same as on.

  • columns_ext (list(str); Optional) – Subset of columns to select from external table before join.

  • drop_duplicates_ext (bool; Default False) – Drop duplicates from external table before join.

  • kind_ext (ExtData; Optional) – Format of df_ext. If nothing is specified, the format will be inferred.

  • cache ({"device", "host", "disk"}) – Where to cache df_ext between transformations. Only used if the data is originally stored on disk. The “host” option is also supported when df_ext is a cudf.DataFrame.

transform(col_selector: nvtabular.columns.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

output_column_names(columns)[source]
compute_output_schema(input_schema, col_selector)[source]