使用平均值进行缺失值插补与填充
在进行分析时,您很可能会使用自己的数据。数据集通常会包含一些缺失值。在本练习中,您将练习对这些缺失值进行插补。插补缺失值很重要,因为您不希望缺失值成为分析的障碍。
pandas 已以别名 pd 导入,NumPy 已以别名 np 导入。已为您加载名为 dataset 的 pandas DataFrame。它包含列 "Total Current Liabilities",其中有一些缺失值。
本练习是课程的一部分
用 Python 分析财务报表
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Impute missing value using average non-missing values by company
impute_by_company = dataset.____
# Impute missing value using average non-missing values by industry
impute_by_comp_type = dataset.____
print(impute_by_company)
print(impute_by_comp_type)