Reputation: 141
Is there a simple way to label encode without using pandas for multiple columns?
Like using only numpy and sklearn's preprocessing.LabelEncoder()
Upvotes: 0
Views: 607
Reputation: 210812
One solution would be to loop through the columns, converting them to numeric values, using LabelEncoder
:
le = LabelEncoder()
cols_2_encode = [1,3,5]
for col in cols_2_encode:
X[:, col] = le.fit_tramsform(X[:, col])
Upvotes: 1