once you have these dependencies loadedlet' get started and engineer some features from categorical data transforming nominal features nominal features or attributes are categorical variables that usually have finite set of distinct discrete values often these values are in string or text format and machine learning algorithms cannot understand them directly hence usually you might need to transform these features into more representative numeric format let' look at new dataset pertaining to video game sales this dataset is also available on kaggle (convenience the following code helps us load this dataset and view some of the attributes of our interest in [ ]vg_df pd read_csv('datasets/vgsales csv'encoding='utf- 'vg_df[['name''platform''year''genre''publisher']iloc[ : out[ ]name platform year genre publisher super mario bros nes platform nintendo mario kart wii wii racing nintendo wii sports resort wii sports nintendo pokemon red/pokemon blue gb role-playing nintendo tetris gb puzzle nintendo new super mario bros ds platform nintendo the dataset depicted in this dataframe shows us various attributes pertaining to video games features like platformgenreand publisher are nominal categorical variables let' now try to transform the video game genre feature into numeric representation do note here that this doesn' indicate that the transformed feature will be numeric feature it will still be discrete valued categorical feature with numbers instead of text for each genre the following code depicts the total distinct genre labels for video games in [ ]genres np unique(vg_df['genre']genres out[ ]array(['action''adventure''fighting''misc''platform''puzzle''racing''role-playing''shooter''simulation''sports''strategy']dtype=objectthis output tells us we have distinct video game genres in our dataset let' transform this feature now using mapping scheme in the following code in [ ]from sklearn preprocessing import labelencoder gle labelencoder(genre_labels gle fit_transform(vg_df['genre']genre_mappings {indexlabel for indexlabel in enumerate(gle classes_)genre_mappings out[ ]{ 'action' 'adventure' 'fighting' 'misc' 'platform' 'puzzle' 'racing' 'role-playing' 'shooter' 'simulation' 'sports' 'strategy'