cugraph.experimental.PropertyGraph.add_edge_data#
- PropertyGraph.add_edge_data(dataframe, vertex_col_names, edge_id_col_name=None, type_name=None, property_columns=None, vector_properties=None, vector_property=None)[source]#
Add a dataframe describing edge properties to the PropertyGraph. Columns not specified as vertex columns are considered properties.
- Parameters:
- dataframeDataFrame-compatible instance
A DataFrame instance with a compatible Pandas-like DataFrame interface.
- vertex_col_nameslist of strings
The column names that contain the values to be used as the source and destination vertex IDs for the edges.
- edge_id_col_namestring, optional
The column name that contains the values to be used as edge IDs, or the name of the index if the index is edge IDs. Specifying the index may be more efficient. If unspecified, edge IDs will be automatically assigned. Currently, all edge data must be added with the same method: either with automatically generated IDs, or from user-provided edge IDs.
- type_namestring, optional
The name to be assigned to the type of property being added. For example, if dataframe contains data about transactions, type_name might be “transactions”. If not specified, the type of properties will be added as the empty string “”.
- property_columnslist of strings, optional
List of column names in the dataframe to be added as properties. All other columns in dataframe will be ignored. If not specified, all property columns in the dataframe are added.
- vector_propertiesdict of string to list of strings, optional
A dict of vector properties to create from columns in the dataframe. Each vector property stores an array for each edge. The dict keys are the new vector property names, and the dict values should be Python lists of column names from which to create the vector property. Columns used to create vector properties won’t be added to the property graph by default, but may be included as properties by including them in the property_columns argument. Use
PropertyGraph.edge_vector_property_to_array
to convert an edge vector property to an array.- vector_propertystring, optional
If provided, all columns not included in other arguments will be used to create a vector property with the given name. This is often used for convenience instead of
vector_properties
when all input properties should be converted to a vector property.
- Returns:
- None
Examples
>>> import cugraph >>> import cudf >>> from cugraph.experimental import PropertyGraph >>> df = cudf.DataFrame(columns=["src", "dst", "some_property"], ... data=[(99, 22, "a"), ... (98, 34, "b"), ... (97, 56, "c"), ... (96, 88, "d"), ... ]) >>> pG = PropertyGraph() >>> pG.add_edge_data(df, vertex_col_names=("src", "dst")) >>> pG.get_num_vertices() 8