in [ ]new_gen_feature_arr gen_ohe transform(new_poke_df[['gen_label']]toarray(new_gen_features pd dataframe(new_gen_feature_arrcolumns=gen_feature_labelsnew_leg_feature_arr leg_ohe transform(new_poke_df[['lgnd_label']]toarray(new_leg_features pd dataframe(new_leg_feature_arrcolumns=leg_feature_labelsnew_poke_ohe pd concat([new_poke_dfnew_gen_featuresnew_leg_features]axis= columns sum([['name''generation''gen_label']gen_feature_labels['legendary''lgnd_label']leg_feature_labels][]new_poke_ohe[columnsfigure - feature set depicting one hot encoded features for new pokemon data points thusyou can see how we used the fit_transformfunctions to engineer features on our dataset and then we were able to use the encoder objects to engineer features on new data using the transformfunction based on the data what it observed previouslyspecifically the distinct categories and their corresponding labels and one hot encodings you should always follow this workflow in the future for any type of feature engineering when you deal with training and test datasets when you build models pandas also provides wonderful function called to_dummies)which helps us easily perform one hot encoding the following code depicts how to achieve this in [ ]gen_onehot_features pd get_dummies(poke_df['generation']pd concat([poke_df[['name''generation']]gen_onehot_features]axis= iloc[ : out[ ]name generation gen gen gen gen gen gen octillery gen helioptile gen dialga gen deoxysdefense forme gen rapidash gen swanna gen the output depicts the one hot encoding scheme for pokemon generation values similar to what we depicted in our previous analyses dummy coding scheme the dummy coding scheme is similar to the one hot encoding schemeexcept in the case of dummy coding schemewhen applied on categorical feature with distinct labelswe get - binary features thus each value of the categorical variable gets converted into vector of size - the extra feature is completely disregarded and thus if the category values range from { - the th or the - th feature is usually represented by vector of all zeros (