I have networkx v. 2.1
. to make it work w/ pandas dataframe, i tried following:
pip3
, this did not work generated
A simple graph:
import pandas as pd
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
# Build a dataframe with 4 connections
df = pd.DataFrame({'from': \['A', 'B', 'C', 'A'\], 'to': \['D', 'A', 'E', 'C'\]})
# Build your graph
G = nx.from_pandas_edgelist(df, 'from', 'to')
# Plot it
nx.draw(G, with_labels=True)
plt.show()