I have a numpy array
z = array(['Iris-setosa', 'Iris-setosa', 'Iris-setosa', 'Iris-setosa','Iris-versicolor', 'Iris-versicolor', 'Iris-versicolor','Iris-virginica', 'Iris-virginica', 'Iris-virginica'])
I want to replace
Iris-setosa -0
Iris-versicolor - 1
Iris-virginica - 2
to apply logistic regression.
Final output should be like
z = [ 0, 0 ,.. 1,1,.. 2,2,..]
Is there a simple way to do this operation instead of iterating through the array and use replace command?
pd.Series(z, dtype="category"), see pandas.pydata.org/pandas-docs/stable/categorical.htmlmachine-learningquestion; please do not spam the tag (removed)