[Numpy-discussion] Inverting argsort(a, axis=0) to obtain column-wise ranks
Thu Sep 9 15:59:42 CDT 2010
Clever and concise (and expect that it works), but isn't this less
efficient? Sorting is O(n*log(n)), while the code I gave is O(n).
Using argsort has the potential to use less memory, though.
On Tuesday, September 7, 2010, Zachary Pincus <email@example.com> wrote:
>> 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?
> NumPy-Discussion mailing list
More information about the NumPy-Discussion