cugraph.experimental.PropertyGraph.add_vertex_data#

PropertyGraph.add_vertex_data(dataframe, vertex_col_name, type_name=None, property_columns=None, vector_properties=None, vector_property=None)[source]#

Add a dataframe describing vertex properties to the PropertyGraph. Can contain additional vertices that will not have associated edges.

Parameters:
dataframeDataFrame-compatible instance

A DataFrame instance with a compatible Pandas-like DataFrame interface.

vertex_col_namestring

The column name that contains the values to be used as vertex IDs, or the name of the index if the index is vertex IDs. Specifying the index may be more efficient.

type_namestring, optional

The name to be assigned to the type of property being added. For example, if dataframe contains data about users, type_name might be “users”. If not specified, the type of properties will be added as the empty string, “”.

property_columnslist of strings, optional

List of column names in dataframe to be added as properties. All other columns in the dataframe will be ignored. If not specified, all columns in 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 vertex. 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.vertex_vector_property_to_array to convert a vertex 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, type_name="etype", vertex_col_names=("src", "dst"))
>>> vert_df = cudf.DataFrame({"vert_id": [99, 22, 98, 34, 97, 56, 96, 88],
...                           "v_prop": [1, 2, 3, 4, 5, 6, 7, 8]})
>>> pG.add_vertex_data(vert_df, type_name="vtype", vertex_col_name="vert_id")
>>> pG.get_vertex_data().sort_index(axis=1)
_TYPE_  _VERTEX_  v_prop
0  vtype        99       1
1  vtype        22       2
2  vtype        98       3
3  vtype        34       4
4  vtype        97       5
5  vtype        56       6
6  vtype        96       7
7  vtype        88       8