開始使用免費開始

目的地

現在要像上一個練習一樣,對 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 = ____
編輯並執行程式碼