Rankordering for nonparametric statistics (Newbie)

Jegenye 2001 Bt jegenye2001 at fw.hu
Sun Oct 12 20:00:00 EDT 2003


What I could make out of your (not too good) description of the problem is
this:

import copy
#M = [[a1_1,a2_1,....a1000_1],[a1_2,a2_2,...], ...]
# test data
M = [[3,56,444,44,45],[34,32,2,3,4]]

res = []
for col in M:
    nc = copy.copy(col)
    nc.sort()
    res.append([col.index(e)+1  for e in nc])
print res

Could not be that elegant but I think it'll do for 1000 numbers.

Best,
  Miklós



Ben Fairbank <baf at texas.antispam.net> wrote in message
news:3f89df93.1184733 at news.houston.sbcglobal.net...
> I have a matrix with many rows(say 1000 to make this concrete) and a
> dozen or so columns.  One column has numbers ranging from 1 to several
> hundred.  I have to create a new column with numbers from 1 to 1000
> corresponding to the smallest to largest numbers (don't worry about
> ties (yet)) in the column of interest.  The new number thus indicate
> the ordinal or rank order of the values in the given column.  I have
> been futzing around with argsort, but cannot find an elegant fast way
> to do it.  Can a reader suggest?
>
> Thank you,
>
> BAFairbank






More information about the Python-list mailing list