[Numpy-discussion] Inverting argsort(a, axis=0) to obtain column-wise ranks
Mon Sep 20 00:19:13 CDT 2010
D'oh, Zachary already gave that answer.
On Sun, Sep 19, 2010 at 10:17 PM, John Schulman <firstname.lastname@example.org> wrote:
> Argsort twice and you get the rank.
> That's because argsort is it's own inverse when applied to the ranks.
> On Tue, Sep 7, 2010 at 1:01 PM, Alexander Michael <email@example.com> wrote:
>> Calculating ranks by inverting the results of an argsort is
>> straightforward and fast for 1D arrays:
>> indices = argsort(a1)
>> ranks = zeros_like(indices)
>> ranks[indices] = arange(len(indices))
>> I was wondering if there was an equally pithy way to do this for
>> multiple data samples stored column-wise in a 2D array. That is, is
>> there a trick to invert the results of argsort(a2, axis=0) without
>> iterating (in python) over the columns?
>> NumPy-Discussion mailing list
More information about the NumPy-Discussion