transform networkx graph to dataframe

Solutions on MaxInterview for transform networkx graph to dataframe by the best coders in the world

showing results for - "transform networkx graph to dataframe"
Christian
13 Jan 2019
1# Get G egdes to dataframe
2edge_df = nx.to_pandas_edgelist(G) 
3
4# Transform networkx nodes to dataframe
5nodelist = list(G.nodes(data=True)) # From G to list
6node_df = pd.DataFrame(nodelist, columns=['vertex', 'name_attribute']) # From list to DF