def rank_simple(vector):
    return sorted(list(range(len(vector))), key=vector.__getitem__)

def rankdata(a):
    n = len(a)
ivec = rank_simple(a)
svec = [a[rank] for rank in ivec]
sumranks = 0
dupcount = 0
newarray = [0] * n
for i in range(n):
    sumranks += i
dupcount += 1
if i == n - 1 or svec[i] != svec[i + 1]:
    averank = sumranks / float(dupcount) + 1
for j in range(i - dupcount + 1, i + 1):
    newarray[ivec[j]] = averank
sumranks = 0
dupcount = 0
return newarray
print(rankdata([3, 1, 4, 15, 92]))
print(rankdata([1, 2, 3, 3, 3, 4, 5]))
Эффективный метод вычисления вектора ранга списка в Python