My dataframe represents a list of edges of a graph and has the following format:
node1 node2 weight
0 a c 1
1 b c 2
2 d c 3
My goal is to generate the equivalent adjacency matrix:
a b c d
a 0 0 1 0
b 0 0 2 0
c 0 0 0 3
d 0 0 0 0
At the moment, while constructing the the dataframe of edges I count the number of nodes and create an NxN data frame and fill in the values manually. what is the pandas way of generating the second dataframe from the first one?