目的地
現在要像上一個練習一樣,對 dest 欄位進行編碼。
本練習屬於課程
PySpark 基礎
練習說明
- 以
StringIndexer()建立名為dest_indexer的StringIndexer,並設定inputCol="dest"與outputCol="dest_index"。 - 以
OneHotEncoder()建立名為dest_encoder的OneHotEncoder,並設定inputCol="dest_index"與outputCol="dest_fact"。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create a StringIndexer
dest_indexer = ____
# Create a OneHotEncoder
dest_encoder = ____