Last active
November 3, 2018 19:17
-
-
Save socratesk/f8d7228d259acb3d82b07256ba475330 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from sklearn import preprocessing | |
countryDF = pd.DataFrame({'id' : [101, 102, 103], | |
'country' : ['NZ', 'BR', 'US']}) | |
labelEncode = preprocessing.LabelEncoder() | |
countryDF['countryLabel'] = labelEncode.fit_transform(countryDF['country']) | |
countryDF.drop(['country'], axis=1, inplace=True) | |
print(countryDF) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment