gen_labels gen_le fit_transform(poke_df['generation']poke_df['gen_label'gen_labels transform and map pokemon legendary status leg_le labelencoder(leg_labels leg_le fit_transform(poke_df['legendary']poke_df['lgnd_label'leg_labels poke_df_sub poke_df[['name''generation''gen_label''legendary''lgnd_label']poke_df_sub iloc[ : out[ ]name generation gen_label legendary lgnd_label octillery gen false helioptile gen false dialga gen true deoxysdefense forme gen true rapidash gen false swanna gen false the features gen_label and lgnd_label now depict the numeric representations of our categorical features let' now apply the one hot encoding scheme on these features using the following code in [ ]encode generation labels using one-hot encoding scheme gen_ohe onehotencoder(gen_feature_arr gen_ohe fit_transform(poke_df[['gen_label']]toarray(gen_feature_labels list(gen_le classes_gen_features pd dataframe(gen_feature_arrcolumns=gen_feature_labelsencode legendary status labels using one-hot encoding scheme leg_ohe onehotencoder(leg_feature_arr leg_ohe fit_transform(poke_df[['lgnd_label']]toarray(leg_feature_labels ['legendary_'+str(cls_labelfor cls_label in leg_le classes_leg_features pd dataframe(leg_feature_arrcolumns=leg_feature_labelsnowyou should remember that you can always encode both the features together using the fit_ transformfunction by passing it two-dimensional array of the two features but we are depicting this encoding for each feature separatelyto make things easier to understand besides thiswe can also create separate dataframes and label them accordingly let' now concatenate these feature frames and see the final result in [ ]poke_df_ohe pd concat([poke_df_subgen_featuresleg_features]axis= columns sum([['name''generation''gen_label'],gen_feature_labels['legendary''lgnd_label'],leg_feature_labels][]poke_df_ohe[columnsiloc[ :