開始使用免費開始

選取特定資料型別

資料集常常會包含多種不同的資料型別(就像你現在使用的這個)。多數機器學習模型要求各個特徵的資料型別要一致。同樣地,多數特徵工程技巧一次也只適用於單一型別的資料。基於這些原因,你在處理 DataFrame 時,常常會需要只取出某些型別的欄位。

前一個練習的 DataFrame(so_survey_df)已經在你的工作環境中。

本練習屬於課程

Feature Engineering for Machine Learning in Python

檢視課程

練習說明

  • 建立 so_survey_df 的子集,只包含數值(intfloat)欄位。
  • 印出 so_survey_df_num 中的欄位名稱。

動手互動練習

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

# Create subset of only the numeric columns
so_numeric_df = so_survey_df.____(____=[____])

# Print the column names contained in so_survey_df_num
print(so_numeric_df.____)
編輯並執行程式碼