欠損データの削除
この演習では、特定の列に欠損値がある行を削除します。対象は length_of_time 列、state 列、そして type 列です。これら3つのうち少なくとも1つに欠損がある行はすべて削除します。
この演習はコースの一部です
Pythonで学ぶMachine Learningの前処理
演習の手順
.isna()と.sum()を使って、length_of_time、state、typeの各列(この順番)の欠損値の数を出力します。- これらの列のうち少なくとも1つに欠損がある行を削除します。
- 新しいデータセット
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(____)