删除缺失数据
在本练习中,您将删除某些列存在缺失值的行。您需要查看 length_of_time 列、state 列和 type 列。只要这三列中任意一列存在缺失值,就删除对应的整行。
本练习是课程的一部分
Python 中的机器学习预处理
练习说明
- 使用
.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(____)