Label Encoder
import pandas as pd
content = ['ham','spam','ham']
df=pd.DataFrame(content,columns={'Sms content'})
df
Sms content | |
---|---|
0 | ham |
1 | spam |
2 | ham |
# encode
from sklearn import preprocessing
encode = preprocessing.LabelEncoder()
df['find spam'] = encode.fit_transform(df['Sms content'])
df
Sms content | find spam | |
---|---|---|
0 | ham | 0 |
1 | spam | 1 |
2 | ham | 0 |