I have a large numpy array:
array([[32, 32, 99, 9, 45], # A
[99, 45, 9, 45, 32],
[45, 45, 99, 99, 32],
[ 9, 9, 32, 45, 99]])
and a large-ish array of unique values in a particular order:
array([ 99, 32, 45, 9]) # B
How can I quickly (no python dictionaries, no copies of A
, no python loops) replace the values in A
so that become the indicies of the values in B
?:
array([[1, 1, 0, 3, 2],
[0, 2, 3, 2, 1],
[2, 2, 0, 0, 1],
[3, 3, 1, 2, 0]])
I feel reaaly dumb for not being able to do this off the top of my head, nor find it in the documentation. Easy points!