from sklearn import preprocessing
le = preprocessing.LabelEncoder()
city = le.fit_transform(["paris", "paris", "tokyo", "amsterdam"])
print(city)
 [1 1 2 0]