title: What do these networkx errors mean which I am getting after setting a filter on my pandas dataframe?
body: <p>I have a source, target and weight dataframe called <code>Gr_Team</code> which looks like this (sample) -</p>
  
  <pre><code>Passer Receiver  count
  116643   102747     27
  102826   169102     10
  116643   102826      7
  167449   102826      8
  102747   167449      4
  </code></pre>
  
  <p>Each Passer and Receiver have their unique x,y co-ordinates which I have in a dictionary <code>loc</code> - <code>{'102739': [32.733999999999995, 26.534], '102747': [81.25847826086964, 27.686739130434784], '102826': [68.09609195402302, 77.52206896551728]}</code>
  I plotted this using networkx:</p>
  
  <pre><code>G=nx.from_pandas_edgelist(Gr_Team, 'Passer', 'Receiver', create_using=nx.DiGraph())
  
  nx.draw(G, loc, with_labels=False, node_color='red',
              node_size=Gr_Team['count']*100,
              width=Gr_Team['count'],
              edge_color = Gr_Team["count"],
              edge_cmap = cmap,
              arrowstyle='-&gt;',
              arrowsize=10,
              vmin=vmin,
              vmax=vmax,
              font_size=10,
              font_weight="bold",
              connectionstyle='arc3, rad=0.1')
  </code></pre>
  
  <p>That worked without any issues and here's what I got:
  <a href="https://i.stack.imgur.com/jawQJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jawQJ.png" alt="enter image description here"></a></p>
  
  <p>However, as soon as I try to filter out all the rows with count value below a constant, let's say 3, using this <code>Gr_Team = Gr_Team[Gr_Team["count"]&gt;3]</code>, I get a key error and here's the entire error and traceback which I can't make anything out of: </p>
  
  <pre><code>Warning (from warnings module):
    File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\networkx\drawing\nx_pylab.py", line 676
      if cb.iterable(node_size):  # many node sizes
  MatplotlibDeprecationWarning: 
  The iterable function was deprecated in Matplotlib 3.1 and will be removed in 3.3. Use np.iterable instead.
  Traceback (most recent call last):
    File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\PassMapOptaF24Networkx.py", line 148, in &lt;module&gt;
      font_weight="bold")#,
    File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\networkx\drawing\nx_pylab.py", line 128, in draw
      draw_networkx(G, pos=pos, ax=ax, **kwds)
    File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\networkx\drawing\nx_pylab.py", line 280, in draw_networkx
      edge_collection = draw_networkx_edges(G, pos, arrows=arrows, **kwds)
    File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\networkx\drawing\nx_pylab.py", line 684, in draw_networkx_edges
      arrow_color = edge_cmap(color_normal(edge_color[i]))
    File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\series.py", line 868, in __getitem__
      result = self.index.get_value(self, key)
    File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\indexes\base.py", line 4375, in get_value
      tz=getattr(series.dtype, 'tz', None))
    File "pandas\_libs\index.pyx", line 81, in pandas._libs.index.IndexEngine.get_value
    File "pandas\_libs\index.pyx", line 89, in pandas._libs.index.IndexEngine.get_value
    File "pandas\_libs\index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc
    File "pandas\_libs\hashtable_class_helper.pxi", line 987, in pandas._libs.hashtable.Int64HashTable.get_item
    File "pandas\_libs\hashtable_class_helper.pxi", line 993, in pandas._libs.hashtable.Int64HashTable.get_item
  KeyError: 1
  </code></pre>
  
  <p>I realized that doing only <code>nx.draw(G, loc, with_labels=False, node_color='red')</code> still worked but as soon as I try to pass <code>node_size</code> or <code>edge_color</code>, it hits the above error. From my understanding, the error is only when I'm using the dataframe <code>Gr_Team</code> in the keyword arguments. </p>
  
  <p>I can't figure out why that's happening and why filtering breaks the code. Any help would be appreciated.</p>
  
  <p><strong>EDIT 1</strong>: <a href="https://gist.github.com/AbhishekSharma99/446116421e8e97fe2dcacb8a0f96a38c" rel="nofollow noreferrer">Here</a>'s a gist of the entire code. I tried my best to keep it minimal. <a href="https://github.com/AbhishekSharma99/Opta-Data-Feed/blob/master/PSGCopy_NancyLyonAllEvents.csv" rel="nofollow noreferrer">Here</a>'s the link to the csv file that needs to be read in as df. The line which produces the error is in also in there; commented out.</p>