简体   繁体   English

TypeError:类型为'int'的对象没有len()?

[英]TypeError: object of type 'int' has no len()?

# Logistic Regression

# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# Importing the dataset
dataset = pd.read_csv('Loan.csv')
X = dataset.iloc[:, 16: 17 ].values
y = dataset.iloc[:, 20].values


# Encoding categorical data
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder = LabelEncoder()
X[:, 0] = labelencoder.fit_transform(X[:, 0])
onehotencoder = OneHotEncoder(categorical_features = 1)
X = onehotencoder.fit_transform(X).toarray()

When i write code i get error at the end like object of type 'int' has no len()? 当我编写代码时,我最终会收到错误,例如类型为'int'的对象没有len()?

It was fixed after a correction was made: 经过更正后,它已修复:

onehotencoder = OneHotEncoder(categorical_features = [1]*)

I think it's because python wants us to specify which column, explaining the need for "[]". 我认为这是因为python希望我们指定哪一列,解释对“ []”的需要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型错误:“int”类型的对象在 python 中没有 len() - TypeError: object of type 'int' has no len() in python 类型错误:“int”类型的对象没有 len() *减法* - TypeError: object of type 'int' has no len() *subtraction* TypeError:类型为'int'的对象没有len()-Python / Pygame - TypeError: object of type 'int' has no len() - Python/Pygame TypeError:“int”类型的 object 在 python(密码生成器)中没有 len() - TypeError: object of type 'int' has no len() in python (Password Generator) 烧瓶形式类型错误:“int”类型的对象没有 len() - Flask form TypeError: object of type 'int' has no len() Builtins.TypeError:类型为'int'的对象没有len() - builtins.TypeError: object of type 'int' has no len() FLASK PYTHON:TypeError:“int”类型的 object 没有 len() - FLASK PYTHON: TypeError: object of type 'int' has no len() 将Django验证程序与admin一起使用-TypeError:“'int'类型的对象没有len()” - Using Django validators with admin - TypeError: “object of type 'int' has no len()” 类型错误:“numpy.int64”类型的对象没有 len() - TypeError: object of type 'numpy.int64' has no len() 调用 Gekko solve 给出 TypeError: object of type 'int' has no len() - Calling Gekko solve gives TypeError: object of type 'int' has no len()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM