NumberMap.unrenumber(df, column_name, preserve_order=False, get_column_names=False)[source]#

Given a DataFrame containing internal vertex ids in the identified column, replace this with external vertex ids. If the renumbering is from a single column, the output dataframe will use the same name for the external vertex identifiers. If the renumbering is from a multi-column input, the output columns will be labeled 0 through n-1 with a suffix of _column_name. Note that this function does not guarantee order or partitioning in multi-GPU mode.

df: cudf.DataFrame or dask_cudf.DataFrame

A DataFrame containing internal vertex identifiers that will be converted into external vertex identifiers.

column_name: string

Name of the column containing the internal vertex id.

preserve_order: bool, optional (default=False)

If True, preserve the ourder of the rows in the output DataFrame to match the input DataFrame

get_column_names: bool, optional (default=False)

If True, the unrenumbered column names are returned.

dfcudf.DataFrame or dask_cudf.DataFrame

The original DataFrame columns exist unmodified. The external vertex identifiers are added to the DataFrame, the internal vertex identifier column is removed from the dataframe.

column_names: string or list of strings

If get_column_names is True, the unrenumbered column names are returned.


>>> from cugraph.structure import number_map
>>> df = cudf.read_csv(datasets_path / 'karate.csv', delimiter=' ',
...                    dtype=['int32', 'int32', 'float32'],
...                    header=None)
>>> df['0'] = df['0'].astype(str)
>>> df['1'] = df['1'].astype(str)
>>> df, number_map = number_map.NumberMap.renumber(df, '0', '1')
>>> G = cugraph.Graph()
>>> G.from_cudf_edgelist(df,
...                      number_map.renumbered_src_col_name,
...                      number_map.renumbered_dst_col_name)
>>> pr = cugraph.pagerank(G, alpha = 0.85, max_iter = 500,
...                       tol = 1.0e-05)
>>> pr = number_map.unrenumber(pr, 'vertex')