[英]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.