[Numpy-discussion] For loop tips

Keith Goodman kwgoodman at gmail.com
Tue Aug 29 15:02:10 CDT 2006


On 8/29/06, Torgil Svensson <torgil.svensson at gmail.com> wrote:
> something like this?
>
> def list2index(L):
>    uL=sorted(set(L))
>    idx=dict((y,x) for x,y in enumerate(uL))
>    return uL,asmatrix(fromiter((idx[x] for x in L),dtype=int))

Wow. That's amazing. Thank you.




More information about the Numpy-discussion mailing list