python - convert text columns into numbers in sklearn -


i'm new data analytics. i'm trying models in python sklearn. have dataset in of columns have text columns. below,

dataset

is there way convert these column values numbers in pandas or sklearn?. assigning numbers these values right?. , if new string pops out in test data?.

please advice.

you can convert them integer codes using categorical datatype.

column = column.astype('category') column_encoded = column.cat.codes 

as long use use tree based model deep enough trees, eg gradientboostingclassifier(max_depth=10), model should able split out categories again.


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -