Is there a fast way to create a numpy array that reduces unique values to their lowest form?

Viewed 189

Sorry if the question is worded confusingly. I have an array similar to the following: [[3,7,9,5],[3,3,7,5]], though much larger.

How can I convert this into a form such as[[0,2,3,1],[0,0,2,1]] where each unique value starting with the lowest is given an identifying number, starting with 0? Currently I am using a for loop, but it is very slow. Is there any functions in numpy that could speed this up?

1 Answers
Related