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

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -