[Numpy-discussion] Inverting argsort(a, axis=0) to obtain column-wise ranks
Zachary Pincus
zachary.pincus at yale.edu
Tue Sep 7 16:06:38 EDT 2010
> indices = argsort(a1)
> ranks = zeros_like(indices)
> ranks[indices] = arange(len(indices))
Doesn't answer your original question directly, but I only recently
learned from this list that the following does the same as the above:
ranks = a1.argsort().argsort()
Will wonders never cease...
So does ranks=a2.argsort(axis=0).argsort(axis=0) then do the trick?
Zach
More information about the NumPy-Discussion
mailing list