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))


d:\pythonenv\py36_ai_env\lib\site-packages\ipykernel_launcher.py:5: DeprecationWarning: This function is deprecated. Please call randint(1, 10 + 1) instead
  """

In [83]:
df


Out[83]:
weight cost 0 b
0 7 4 A D
1 8 5 B A
2 7 10 C E

In [84]:
G['E']['C']['cost']
# G[7][10]['cost']


Out[84]:
10