If you don't want to split ties nor handle NaNs:
>> (-a).argsort().argsort() + 1
array([5, 3, 1, 2, 6, 4])
To handle ties you can use:
from scipy.stats import rankdata
To handle ties and NaNs, you can use the labeled array package, la:
>> import la
>> lar = la.larry([0.012, 0.08, 2, 0.5, 0.010, 0.03])
>> (-lar).ranking(norm='0,N-1').A + 1
array([ 5., 3., 1., 2., 6., 4.])
_______________________________________________
SciPy-User mailing list
SciPy...@scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
Oh, actually la has a pure array version:
>> a = np.array([0.012, 0.08, 2, 0.5, 0.010, 0.03])
>> from la.afunc import ranking
>> ranking(-a, norm='0,N-1') + 1
Did you mean
import numpy as np
a = np.array([ 0.012, 0.08, 2, 0.5, 0.010, 0.03])
index = np.argsort(a)[::-1]
b = a[index]
print b
[ 2. 0.5 0.08 0.03 0.012 0.01 ]
Mart
> _______________________________________________
> SciPy-User mailing list
> SciPy...@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
--
View this message in context: http://old.nabble.com/Ranking-a-list-of-numbers-tp28768184p28770319.html
Sent from the Scipy-User mailing list archive at Nabble.com.