我想在我的一个数据集上执行IsolationForest算法。 已经调用了库,读取了csv文件,我只想使用两列,所以我只包括这两列
df = pd.read_csv('Dataset.csv', encoding='latin')
df=df[[‘numbers_column’, 'text_column']]
其中一列有string/test,所以我尝试使用编码器将其转换为数字
for col in df.columns:
if df[col].dtype == "text_column":
encoded= LabelEncoder()
encoded.fit(df[col])
df[col]=encoded.transform(df[col])
然而,在这样做时,我得到了以下错误
AttributeError: 'numpy.ndarray' object has no attribute 'columns'
我在网上查过类似的问题,它们只是训练和测试数据的例子
目前没有回答
相关问题 更多 >
编程相关推荐