Created
September 5, 2017 08:32
-
-
Save volf52/fb784873cd71edb4152b1f8f302d3339 to your computer and use it in GitHub Desktop.
Ranking a data set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ranking(arr): | |
cp = [] | |
for x in arr: | |
if cp.count(x) == 0: | |
cp.append(x) | |
cp.sort() | |
ranks = {x:y for x,y in zip(cp, range(1, len(cp)+1))} | |
return [ranks[x] for x in arr] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment