Carrier
In this exercise you'll create a StringIndexer and a OneHotEncoder to code the carrier column. To do this, you'll call the class constructors with the arguments inputCol and outputCol.
The inputCol is the name of the column you want to index or encode, and the outputCol is the name of the new column that the Transformer should create.
Questo esercizio fa parte del corso
Foundations of PySpark
Istruzioni dell'esercizio
- Create a
StringIndexercalledcarr_indexerby callingStringIndexer()withinputCol="carrier"andoutputCol="carrier_index". - Create a
OneHotEncodercalledcarr_encoderby callingOneHotEncoder()withinputCol="carrier_index"andoutputCol="carrier_fact".
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# Create a StringIndexer
carr_indexer = StringIndexer(____)
# Create a OneHotEncoder
carr_encoder = OneHotEncoder(____)