Hi all. I am embarrassed to ask this here, but I just cannot figure it out.
Suppose we have a big numpy array
y_train
array([‘wesmea’, ‘whtspa’, ‘hoowar’, …, ‘gcrfin’, ‘boboli’, ‘buffle’],
dtype=’<U7’)
and a much smaller numpy array of the unique names in y_train
y_unique
array([‘aldfly’, ‘ameavo’, ‘amebit’, ‘amecro’, ‘amegfi’, ‘amekes’,
‘amepip’, ‘amered’, ‘amerob’…])
How do I derive the index of every element of y_train into y_unique? Like,
array([200, 201, 23, ...,27, 5, 6'])
Does this task really require a loop? Or a list comprehension outside of numpy?
Perplexed, Malcolm
P.S. I see np.unique with return_inverse, but in this situation y_unique contains more than the unique values in y_train.