I'm trying to convert a string array of categorical variables to an integer array of categorical variables.
Ex.
import numpy as np
a = np.array( ['a', 'b', 'c', 'a', 'b', 'c'])
print a.dtype
>>> |S1
b = np.unique(a)
print b
>>> ['a' 'b' 'c']
c = a.desired_function(b)
print c, c.dtype
>>> [1,2,3,1,2,3] int32
I realize this can be done with a loop but I imagine there is an easier way. Thanks.