[Numpy-discussion] Inverting argsort(a, axis=0) to obtain column-wise ranks

Zachary Pincus zachary.pincus@yale....
Tue Sep 7 15:06:38 CDT 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