刪除遺漏資料
在這個練習中,你要移除部分在特定欄位含有遺漏值的列。你將檢查 length_of_time、state 和 type 這三個欄位。只要任一列在這三個欄位中有至少一個遺漏值,就把該列刪除。
本練習屬於課程
Python 的 Machine Learning 前處理
練習說明
- 使用
.isna()和.sum(),依序列印出length_of_time、state、type三個欄位各自的遺漏值數量。 - 刪除在上述任一欄位中有遺漏值的列。
- 列印新的資料集
ufo_no_missing的shape。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Count the missing values in the length_of_time, state, and type columns, in that order
print(ufo[[____, ____, ____]].____.____)
# Drop rows where length_of_time, state, or type are missing
ufo_no_missing = ____
# Print out the shape of the new dataset
print(____)