I am newbie in python,
I have a huge dataframe
:
Person OD
A BS1
A BS2
B BS4
B BS8
C BS5
C BS1
D BS9
D BS7
E BS2
E BS7
F BS2
F BS1
G BS1
G BS2
is it possible to transform into an origin-destination (OD) matrix in python-pandas? Example from BS1 to BS2 there is 2 person (A and G) then in OD matrix 2 people into BS1-BS2.
my expected result:
O/D BS1 BS2 BS3 BS4 BS5 BS6 BS7 BS8 BS9
BS1 2
BS2 1 1
BS3
BS4 1
BS5 1
BS6
BS7
BS8
BS9 1
how to do it? thanks a lot