Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

label encoding column pandas

import seaborn as sns 
df = sns.load_dataset('iris')
df['species'] = df['species'].astype('category').cat.codes
df.head(3)
'''sepal_length	sepal_width	petal_length	petal_width	species
	5.1					3.5			1.4					0.2			0
	4.9					3.0			1.4					0.2			0
	4.7					3.2			1.3					0.2			0'''
 
PREVIOUS NEXT
Tagged: #label #encoding #column #pandas
ADD COMMENT
Topic
Name
2+9 =