In [82]:
import pandas as pd
import numpy as np
import networkx as nx
r = np.random.RandomState(seed=42)
ints = r.random_integers(1, 10, size=(3,2))
# ints = r.randint(1, 11)
a = ['A', 'B', 'C']
b = ['D', 'A', 'E']
df = pd.DataFrame(ints, columns=['weight', 'cost'])
df[0] = a
df['b'] = b
G=nx.from_pandas_dataframe(df, 0, 'b', list(df))
In [83]:
df
Out[83]:
In [84]:
G['E']['C']['cost']
# G[7][10]['cost']
Out[84]: