title: Edgelist from pandas dataframe with nodes of different colours
body: <p>I have the following data frame:</p>
  <pre><code>Src  Dst
  A    [A,B]
  B    [B,A]
  C    [C]
  D    [D,E,F]
  E    [E,D,F]
  F    [F,D,E]
  ...
  </code></pre>
  <p>I would like to generate a network where <code>Src</code> is nodes, <code>Dst</code> are edges, and where a new column, <code>Weight</code>, can assign a different colour (green) to the node which is <code>A</code> or D, while the others are all the same (e.g. blue).</p>
  <p>I have tried as follows:</p>
  <h1>Create a new column Weight</h1>
  <pre><code>nd=[&quot;A&quot;,&quot;D&quot;]
  df['Weight'] = np.where(df.Src.isin(nd), 1, 0)
  </code></pre>
  <p>The problem is here that I do not know how to assign a colour, so I just tried to assign values 1 for A or D and 0 for all the other values, and separately to change colours.</p>
  <p>For the graph, I used the following</p>
  <pre><code>G = nx.from_pandas_edgelist(df, 'Src', 'Dst')
  </code></pre>
  <p>The above line of code does not connect with lines the nodes in Dst, and I cannot understand the reason.<br />
  I have found something that might be helpful in assigning colours:</p>
  <pre><code>   colors=[]
  for n in df.Src:
      if n in df.Weight:
          colors.append('g')
      else:
          colors.append('b')
  
  # nodes
  nx.draw_networkx_nodes(G,pos, node_color = colors)
  </code></pre>
  <p>but I have got this error:</p>
  <blockquote>
  <p>ValueError: 'c' argument has 79 elements, which is inconsistent with
  'x' and 'y' with size 76.</p>
  </blockquote>
  <p>The image below would be something similar to my expected output (<code>A</code> and <code>D</code> nodes green, others blue, and links based on <code>Dst</code> data; please note that the image below does NOT currently reproduce neither the colour nor the edges expected).</p>
  <p><a href="https://i.stack.imgur.com/tuXkf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tuXkf.png" alt="enter image description here" /></a></p>
  <p>Could you please help me giving me advice on how to do it?</p>