I am trying to figure out a way to take a numpy array of integers, then change the entries such that the smallest is 0, the second smallest is 1, etc.
E.g.
Start with this
In [13]: a = numpy.array([[1, 2, 10],[1, 2, 99]])
In [14]: a
Out[14]:
array([[ 1, 2, 10],
[ 1, 2, 99]])
And get this:
array([[ 0, 1, 2],
[ 0, 1, 3]])
I can start to see the way through with numpy.unique(), e.g.
In [19]: range(len(b))
Out[19]: [0, 1, 2, 3]
In [20]: b = numpy.unique(a)
In [21]: b
Out[21]: array([ 1, 2, 10, 99])
In [22]: c = range(len(b))
In [23]: c
Out[23]: [0, 1, 2, 3]
Seems like I should now be able to use b and c to translate from one array to the other. But what's the best (and quickest) way to do this?