xgi.convert.pandas#
Methods for converting to and from a Pandas dataframe.
Functions
- from_bipartite_pandas_dataframe(df, create_using=None, node_column=0, edge_column=1)[source]#
Create a hypergraph from a pandas dataframe given specified node and edge columns.
- Parameters:
df (Pandas dataframe) – A dataframe where specified columns list the node IDs and the associated edge IDs
create_using (Hypergraph constructor, optional) – The hypergraph object to add the data to, by default None
node_column (hashable, optional) – The column with the node IDs, by default 0 Can specify names or indices
edge_column (hashable, optional) – The column with the edge IDs, by default 1 Can specify names or indices
- Returns:
The constructed hypergraph
- Return type:
Hypergraph object
- Raises:
XGIError – Raises an error if the user specifies invalid column names
- to_bipartite_pandas_dataframe(H)[source]#
Create a two column dataframe from a hypergraph.
- Parameters:
H (Hypergraph or Simplicial Complex) – A dataframe where specified columns list the node IDs and the associated edge IDs
- Returns:
A two column dataframe
- Return type:
Pandas Dataframe object
- Raises:
XGIError – Raises an error if the user specifies invalid column names