while the categorical features were expanded into one new feature for each possible valuein[ ]data_dummies head(out[ ]age hoursworkclass_ perweek workclass_ workclass_ federallocal-gov gov occupation_ techsupport occupation_ income_ income_ transport moving rows columns we can now use the values attribute to convert the data_dummies dataframe into numpy arrayand then train machine learning model on it be careful to separate the target variable (which is now encoded in two income columnsfrom the data before training model including the output variableor some derived property of the output variableinto the feature representation is very common mistake in building supervised machine learning models be carefulcolumn indexing in pandas includes the end of the rangeso 'age':'occupation_ transport-movingis inclusive of occupation_ transport-moving this is different from slicing numpy arraywhere the end of range is not includedfor examplenp arange( )[ : doesn' include the entry with index in this casewe extract only the columns containing features--that isall columns from age to occupation_ transport-moving this range contains all the features but not the targetin[ ]features data_dummies ix[:'age':'occupation_ transport-moving'extract numpy arrays features values data_dummies['income_ > 'values print(" shape{ shape{}format( shapey shape) representing data and engineering features