I\'m looking for an efficient way to calculate the rank vector of a list in Python, similar to R\'s rank function. In a simple list with no ties between the ele
rank
This works for the spearman correlation coefficient .
def get_rank(X, n): x_rank = dict((x, i+1) for i, x in enumerate(sorted(set(X)))) return [x_rank[x] for x in X]