Answers for "how to convert string labels to numpy array"

0

how to convert string labels to numpy array

print (pd.factorize(L)[0])
[0 1 2 1 0]
Posted by: Guest on July-30-2020
0

how to convert string labels to numpy array

L = ['ABC', 'DEF', 'GHI', 'DEF', 'ABC']

print (np.unique(L, return_inverse=True)[1])
[0 1 2 1 0]
Posted by: Guest on July-30-2020

Code answers related to "how to convert string labels to numpy array"

Python Answers by Framework

Browse Popular Code Answers by Language