開始使用免費開始

手動特徵擷取 II

你正在處理 ANSUR 資料集的變體 height_df,其中每個人的身高量測了 3 次:height_1height_2height_3。請在資料集中新增一個「平均身高」特徵,然後刪除原本的 3 個特徵。

本練習屬於課程

Python 的降維

檢視課程

練習說明

  • 在資料集中新增一個平均身高特徵。使用 .mean() 方法並設定 axis=1
  • 從資料集中刪除原本的 3 個身高特徵。

動手互動練習

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

# Calculate the mean height
height_df['height'] = height_df[[____]].____

# Drop the 3 original height features
reduced_df = height_df.drop(____, axis=1)

print(reduced_df.head())
編輯並執行程式碼