Simple numpy question
Posted
by dassouki
on Stack Overflow
See other posts from Stack Overflow
or by dassouki
Published on 2010-05-27T14:42:27Z
Indexed on
2010/05/27
15:01 UTC
Read the original article
Hit count: 264
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]
© Stack Overflow or respective owner