Hello I have the following code, in order to do a matrix of adjacency, but I have the weight by peer in another column, how can do the adjacency matrix in panda with this data?
Current code:
ady = pd.read_csv("edges.csv", sep=',')[['Source', 'Target', 'weight']]
ady['weight'] = pd.to_numeric(ady['weight'])
ady = pd.crosstab(ady.Source, ady.Target, ady.weight, aggfunc = sum)
Data:
Source, Target, weight
a,b,2
a,c,1
b,a,2
b,b,1
c,a,1
Expected data:
a,b,c
a 0,2,1
b 2,1,0
c 1,0,0
dtypes:
ady.dtypes
Source object
Target object
weight float64
Original data: https://pastebin.com/Y55a64yz
Any idea?
Thanks