Python Forum
ValueError: dictionary update sequence element #0 has length 1; 2
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ValueError: dictionary update sequence element #0 has length 1; 2
#3
changing 1 to 2 still pops the following error

# open nodes
with open('Twitter_SNA/nodes.csv', 'r')as nodescsv:
    nonreader = csv.reader(nodescsv)
    nodes2 = [n for n in nonreader][1:] # get list of node names
node_names = [n[0] for n in nodes2]
# open edges
with open('Twitter_SNA/edges.csv') as edgecsv:
    edgereader = csv.reader(edgecsv)
    edges3 = [tuple(e) for e in edgereader][2:] # retrieve list of edges

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-84-1da2e7f196f3> in <module>
      1 G.add_nodes_from(node_names)
----> 2 G.add_edges_from(edges3)

~\Anaconda3\lib\site-packages\networkx\classes\graph.py in add_edges_from(self, ebunch_to_add, **attr)
    976             datadict = self._adj[u].get(v, self.edge_attr_dict_factory())
    977             datadict.update(attr)
--> 978             datadict.update(dd)
    979             self._adj[u][v] = datadict
    980             self._adj[v][u] = datadict

ValueError: dictionary update sequence element #0 has length 1; 2 is required
Reply


Messages In This Thread
RE: ValueError: dictionary update sequence element #0 has length 1; 2 - by Jmekubo - Apr-28-2019, 02:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  which exception should be thrown for a sequence of the wrong length? Skaperen 1 893 Jan-06-2023, 04:13 AM
Last Post: deanhystad
  ValueError: Length mismatch: Expected axis has 8 elements, new values have 1 elements ilknurg 1 5,303 May-17-2022, 11:38 AM
Last Post: Larz60+
  check if element is in a list in a dictionary value ambrozote 4 2,072 May-11-2022, 06:05 PM
Last Post: deanhystad
  Why is dictionary length not 20? Mark17 2 1,783 Oct-07-2021, 05:56 PM
Last Post: Mark17
Question Python + Google Sheet | Best way to update specific cells in a single Update()? Vokofe 1 2,746 Dec-16-2020, 05:26 AM
Last Post: Vokofe
  removing dictionary element in list using (key, value) MelonMusk 3 2,343 Jun-13-2020, 02:37 PM
Last Post: buran
  Highlight/Underline a string | ValueError: zero length field name in format searching1 1 3,060 Jul-01-2019, 03:06 AM
Last Post: metulburr
  update values in list based on dictionary bunti 3 2,893 Jun-10-2019, 07:26 AM
Last Post: perfringo
  compare element of a dictionary Amniote 1 2,197 May-23-2019, 05:21 PM
Last Post: woooee
  Unable to locate element no such element gahhon 6 4,581 Feb-18-2019, 02:09 PM
Last Post: gahhon

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020