On Wed, Nov 4, 2009 at 14:21, Alan G Isaac <ais...@american.edu> wrote: > On 11/4/2009 3:09 PM, David Warde-Farley wrote: >> I'd like to map every unique element (these could be strings, objects, >> or already ints) to a unique integer between 0 and len(unique(d)) - 1. > > mymap = dict((k,v) for v,k in enumerate(set(a)))
I'd toss in a sorted() just to keep the mapping stable. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion