始める無料で始める

欠損データの削除

この演習では、特定の列に欠損値がある行を削除します。対象は length_of_time 列、state 列、そして type 列です。これら3つのうち少なくとも1つに欠損がある行はすべて削除します。

この演習はコースの一部です

Pythonで学ぶMachine Learningの前処理

コースを見る

演習の手順

  • .isna().sum() を使って、length_of_timestatetype の各列(この順番)の欠損値の数を出力します。
  • これらの列のうち少なくとも1つに欠損がある行を削除します。
  • 新しいデータセット ufo_no_missingshape を出力します。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

# 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(____)
コードを編集して実行