Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

label encoding in pandas

# Import label encoder
from sklearn import preprocessing
  
# label_encoder object knows how to understand word labels.
label_encoder = preprocessing.LabelEncoder()
  
# Encode labels in column 'species'.
df['species']= label_encoder.fit_transform(df['species'])
  
df['species'].unique()
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #label #encoding #pandas
ADD COMMENT
Topic
Name
4+4 =