“ 1000_Companies.csv”中数组的索引过多

时间:2019-10-19 07:01:00

标签: python arrays pandas numpy linear-regression

import numpy as np
import pandas as pd

companies = pd.read_csv('1000_Companies.csv')

X = companies.iloc[:, -1].values
y = companies.iloc[:, 4].values

from sklearn.preprocessing import LabelEncoder, OneHotEncoder

labelencoder = LabelEncoder()

# I'm getting "too many indices for array" error in this line.
X[:, 3] = labelencoder.fit_transform(X[:, 3])

onehotencoder = OneHotEncoder(categorical_features = [3])

X = onehotencoder.fit_transform(X).toarray()
print("X = ", X)

我是python的新手,几分钟前刚刚开始学习“机器学习”。我对Python和其他“ numpy”或AI的知识了解不多。但是我在C ++和C#方面经验丰富。请帮助我。

我正在使用Visual Studio 2019 Professional

您可以查看this图片以了解更多详细信息。

0 个答案:

没有答案