Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

label encoding of a column in python

import seaborn as sns 
df = sns.load_dataset('iris')
def encode(x):
    for i,j in enumerate(df['species'].unique()):
        if x == j:
            return i

df['species'] = df['species'].apply(lambda x:encode(x))
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #label #encoding #column #python
ADD COMMENT
Topic
Name
8+8 =