I'm trying to return an array which has the rank of each value in an array. For example, given the array below:
import numpy as np
arr1 = np.array([4, 5, 3, 1])
I would want to return the array:
array([2, 3, 1, 0])
Such that the values in the returned array indicate the ascending order of the array (ie, the value in the returned array indicates which is largest). Using argsort, I can only tell how the values should be reordered:
arr1.argsort()
array([3, 2, 0, 1])
Let me know if this is unclear.