You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行AutoClean代码为何出现‘str’ object has no attribute ‘copy’错误?

问题解决:AutoClean运行报错AttributeError

错误原因

AutoClean的__init__方法需要接收pandas DataFrame对象作为输入,但你直接传入了Excel文件路径的字符串,字符串没有copy()方法,因此触发报错。

修正后的代码

from AutoClean.autoclean import AutoClean
import pandas as pd

# 先用pandas读取Excel文件,生成DataFrame对象
resultat = pd.read_excel('result(11).xlsx')
# 将DataFrame传入AutoClean初始化
pipeline = AutoClean(resultat)
# 获取清洗后的结果
cleaned_data = pipeline.output

额外说明

  • 原代码中的for pipeline in self.pipeline:存在错误:self在此处无定义,且AutoClean实例的output是直接可访问的属性,无需循环遍历。
  • 若需要自定义清洗规则,可在初始化AutoClean时传入对应参数(如mode='auto'、missing_num='mean'等)。

内容的提问来源于stack exchange,提问作者Radia

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 09:45:36