networkcommons.utils.network_from_df

networkcommons.utils.network_from_df(network_df, source_col='source', target_col='target', directed=True)

Create a network from a DataFrame.

Parameters:
  • df (DataFrame) – DataFrame containing the network data.

  • source_col (str) – Column name for the source nodes.

  • target_col (str) – Column name for the target nodes.

  • directed (bool) – Whether the network is directed or not.

Returns:

The network.

Return type:

nx.Graph or nx.DiGraph