试图从sklearn中导入插补器,

import pandas as pd
dataset = pd.read_csv('Data.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, 3].values

#PART WHERE ERROR OCCURS:-
from sklearn.preprocessing import Imputer

显示"ImportError:无法从'sklearn.preprocessing'(/home/codeknight13/anaconda3/lib/python3.7/site packages/sklearn/preprocessing/____;init.py)导入名称'Imputer'"

推荐答案

from sklearn.preprocessing import Imputerscikit-learn v0.20.4一起被弃用,从v0.22.2年起被删除.

from sklearn.impute import SimpleImputer
imputer = SimpleImputer(missing_values=np.nan, strategy='mean')

Python-3.x相关问答推荐

如何在Python Matplotlib中在x轴上放置点

在Python中从mySQL获取多行

为什么打印语句在Python多处理脚本中执行两次?

在循环访问XML中的多个层时,xml.etree.Elementree Python3解析器不起作用

如何使用Python将嵌套的XML转换为CSV

在循环中使用Print&S结束参数时出现奇怪的问题

Heroku 中的未知错误代码缺少一个或多个参数

DataFrame列中如何迭代重复值?

过滤阈值大小数据以使用 Pyspark 或 Python 读取

Python多进程:运行一个类的多个实例,将所有子进程保留在内存中

过滤查询集和Q运算符的不同值

Semaphore信号量 Python 的工作原理

请求:RecursionError:超出最大递归深度

使用逗号时,除了处理程序中的语法无效

在python中,如果一个函数没有return语句,它会返回什么?

在没有时间的python中创建日期

为 Python 3 和 PyQt 构建可执行文件

使用完整路径激活 conda 环境

命名参数可以与 Python 枚举一起使用吗?

如何为 anaconda python3 安装 gi 模块?