title: Python: best way to create a network?
body: <p>I have a dataframe containing the information of transactions between two companies</p>
  
  <pre><code>df    
        idA   idB   amount  nameA  nameB
  0      4     5     300     xxx    yyy
  1      3     7     150     kkk    uuu 
  2      3     6     289     kkk    vvv
  3      1     4     189     hhh    iii
  </code></pre>
  
  <p>I want to create a network using the the <code>networkx</code> package.</p>
  
  <pre><code>G=nx.Graph()
  for i in df.index:
      G.add_node(df['idA'][i], name = df['nameA'][i])
      G.add_node(df['idB'][i], name = df['nameB'][i])
      G.add_edge(df['idA'][i], df['idB'][i], weight = df['amount'][i] )
  </code></pre>
  
  <p>I am wondering if there is a more efficient way</p>