Networkx / Data Science - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Networkx / Data Science (/thread-29598.html) |
Networkx / Data Science - IamAlbert - Sep-11-2020 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 |