返回

python-OneHotEncoder、仅错误整数、切片 (`:`)、省略号 (`...`)、numpy.newaxis (`None`) 和整数或布尔数组是有效索引

发布时间:2022-05-12 09:54:59 247
# node.js

感谢您抽出时间阅读此问题。

在尝试对凌乱的数据集(数据类型:float64(16)、object(6)以及一些缺少的值)进行编码时遇到此错误。

for column in categorial_columns:
    np_feature = feature[column].to_numpy()
    tempdf = ohe.fit_transform(np_feature[column])
    df = pd.merge(
        left=feature,
        right=tempdf,
        left_index=True,
        right_index=True,
    )
    feature_encoded = df.drop(columns=column)

错误如下所示:

Traceback (most recent call last):
  File "../Data Cleaning.py", line 29, in 
    tempdf = ohe.fit_transform(np_feature[column])
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

再次感谢您抽出时间!!

特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(0)
按点赞数排序
用户头像