開始使用免費開始

檢查欄位型別

使用 .info() 方法查看 UFO 資料集的欄位型別。有兩個欄位需要轉換:seconds 欄位是數值欄位,但目前被讀成 object;以及 date 欄位,可以轉換成 datetime 型別。這樣之後做特徵工程會更容易。

本練習屬於課程

Python 的 Machine Learning 前處理

檢視課程

練習說明

  • ufo 資料集呼叫 .info() 方法。
  • seconds 欄位的型別轉為 float
  • date 欄位的型別轉為 datetime
  • 再次對 ufo 呼叫 .info(),檢查變更是否生效。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Print the DataFrame info
print(ufo.____)

# Change the type of seconds to float
ufo["seconds"] = ____

# Change the date column to type datetime
ufo["date"] = ____

# Check the column types
print(ufo.____)
編輯並執行程式碼