msticpy.transform.network module

Module for converting DataFrame to Networkx graph.

msticpy.transform.network.df_to_networkx(data, source_col, target_col, source_attrs=None, target_attrs=None, edge_attrs=None, graph_type='graph')

Create a networkx graph from a DataFrame.

Parameters:
  • data (pd.DataFrame) – Input data

  • source_col (str) – Column for source nodes.

  • target_col (str) – Column for target nodes.

  • source_attrs (Optional[List[str]], optional) – Optional list of columns to use as source node attributes, by default None

  • target_attrs (Optional[List[str]], optional) – Optional list of columns to use as target node attributes, by default None

  • edge_attrs (Optional[List[str]], optional) – Optional list of columns to use as edge node attributes, by default None

  • graph_type (str) – “graph” or “digraph” (for nx.DiGraph)

Returns:

The networkx graph object

Return type:

nx.Graph