![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/95ff40f779a363c5fcb0ae47dbb9e311.png)
以下,是我整理汇总出来的,一些关于用Python的pandas库实现缺失值处理的基础脚本。篇幅和时间的原因,原理不作赘述,数据源与运行结果亦不作展示,具体代码如下所示:
**
01. 构造数据集
**
import pandas as pd
import numpy as np
df = pd.DataFrame({
"品类":["蔬菜","水果","水产","蔬菜","水果","水产","蔬菜","水果","水产","肉类"],
"商品":["白菜","苹果","鲫鱼","土豆","雪梨","鲈鱼","菜花","沙梨","河虾","牛肉"]