Computer scienceData scienceInstrumentsPandasData preprocessing with pandas

Preprocessing categorical features with pandas

Encoding with LabelEncoder

Report a typo

Download the provided file and read it using pandas. Encode the "Hero_Name" column using LabelEncoder from scikit-learn. Create a new column called "Hero_Name_encoded" to store the encoded values. The answer should be a copy of the output from the print() function applied to 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  Hero_Name_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