Hei,
I have different city names in the column "City" in my dataset. I would love to encode it using LabelEncoder(). However, I got quite frustrating results with negative values
df['city_enc'] = LabelEncoder().fit_transform(df['City']).astype('int8')
The new city_enc column gives me values from -128 to 127. I do not understand why LabelEncoder().fit_transform gives me negative values? I expect that it would give value from 0 to (n-1). Can anyone explain this to me?
Best regards, Lan Nguyen