Given two DataFrames, one for Nodes and another for Edges. How can I get those into a networkx graph including the attribute columns I have?
Example:
df_nodes
| ID | Label | Attribute_W | Attribute_X | |
|---|---|---|---|---|
| 0 | 0 | Japan | Asia | 81 |
| 1 | 1 | Mexico | America | 52 |
| 2 | 2 | Ireland | Europe | 353 |
df_Edges
| Target | Source | Attribute_Y | Attribute_Z | |
|---|---|---|---|---|
| 0 | 0 | 1 | 10 | 1 |
| 1 | 0 | 2 | 15 | 2 |
| 2 | 1 | 2 | 20 | 3 |
I tried with G = nx.from_pandas_edgelist but it returns an attribute error. And I'm not sure of how to add the attributes in the construction of the graph.
I'm looking to output a graphml file nx.write_graphml(G, "My_File.graphml")
Thanks.