[Numpy-discussion] For loop tips

Alan G Isaac aisaac at american.edu
Tue Aug 29 14:13:54 CDT 2006


You can get some speed up for numeric data:
def list2index2(L):
  aL = asarray(L)
  eL = empty_like(L)
  for v,k in enumerate(set(L)):
  	eL[aL == k] = v
  return numpy.asmatrix(eL).T

fwiw,
Alan Isaac





More information about the Numpy-discussion mailing list