Computer scienceData scienceInstrumentsPandasData preprocessing with pandas

Preprocessing categorical features with pandas

Ordinal Encoding

Report a typo

Download the provided file and read it using pandas. Encode "Hero_Name" column according to the ordinal target encoding method. Create an encoded column "Ordinal_Hero_Encoded". The answer should be a copy of the output of print() function of the first 5 rows of the dataset as shown in the example below.

# Copy the output and paste it as an answer. 

           City      Hero_Name  Number_of_Heroes  Ordinal_Hero_Encoded
0    Metropolis         Batman                10                  0
1   Gotham City       Superman                 9                  0
2       Wakanda  Black Panther                17                  0
3  Central City       Superman                13                  0
4       Wakanda    Green Arrow                12                  0
Write code in your IDE to process the text file and display the results below
___

Create a free account to access the full topic