Simple numpy question
- by dassouki
I can't get this snippet to work:
#base code
A = array([ [ 1, 2, 10 ],
[ 1, 3, 20 ],
[ 1, 4, 30 ],
[ 2, 1, 15 ],
[ 2, 3, 25 ],
[ 2, 4, 35 ],
[ 3, 1, 17 ],
[ 3, 2, 27 ],
[ 3, 4, 37 ],
[ 4, 1, 13 ],
[ 4, 2, 23 ],
[ 4, 3, 33 ] ])
# Number of zones
zones = unique1d(A[:,0])
for origin in zones:
for destination in zones:
if origin != destination:
A_ik = A[(A[:,0] == origin & A[:,1] == destination), 2]