Python Forum
Networkx / Data Science
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Networkx / Data Science
#1
Hello,

i need your help with a project. I want to use Networkx to analyze relationships between data. For a first test I have the following database:

Document "node.csv" which includes the names for a Company, for example:
Company
A
B
C
...


And Document "edges.csv" which includes the Connections for a Company, for example:

Company, Employee
A, Max
B, John
C, Frank
...

With the following code I get the connection between the employees and the company:


with open('node.csv', 'r') as nodecsv:
    nodereader = csv.reader(nodecsv)
    nodes = [n for n in nodereader][1:]

node_names = [n[0] for n in nodes]

with open('edges.csv', 'r') as edgecsv:
    edgereader = csv.reader(edgecsv)
    edges = [tuple(e) for e in edgereader][1:]

G=nx.Graph()
G.add_nodes_from(node_names)
G.add_edges_from(edges)
print(nx.info(G))

nx.draw(G, with_labels = True, edge_color = 'g')
But my problem is that I have several employees at the company. If I now add more employees in Excel, I get the following error message in Python:

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


The Excel list should look like this:

Company, Employee
A, Max, Anna, Jennifer
B, John
C, Frank, Michael
...


Many thanks in advance!
Albert
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Data Science Roadmap for Career Advancement shiv11 0 167 Apr-04-2024, 11:10 AM
Last Post: shiv11
  Data Science Oshadha 2 1,259 Jun-30-2022, 04:59 PM
Last Post: Larz60+
  Data Science - "key of type tuple not found and not a MultiIndex" priyanshuaggarwal 0 5,206 Nov-07-2021, 11:22 PM
Last Post: priyanshuaggarwal
  What good book in Data science ? bashar 0 1,804 Apr-14-2020, 03:29 AM
Last Post: bashar
  WGET + Data Science + Python Programs BrandonKastning 0 1,632 Mar-29-2020, 06:43 PM
Last Post: BrandonKastning
  Data science with Python - links with exercises darpInd 1 2,002 Mar-02-2020, 04:24 PM
Last Post: Larz60+
  Softwares to learn data science jk91 2 2,345 Feb-26-2020, 07:17 PM
Last Post: jefsummers
  Data Science Project DaisyPJ 3 2,738 Jan-19-2020, 07:05 PM
Last Post: jefsummers
  Nvidia or (25% better for the price) Radeon GPU for Python Data Science gheek 0 1,674 Dec-11-2019, 05:19 PM
Last Post: gheek
  networkx to show traffic help to get started paul41 0 1,649 Nov-23-2019, 05:19 PM
Last Post: paul41

Forum Jump:

User Panel Messages

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