这是什么原因,怎么修改?麻烦大家帮忙看一下这是什么原因呀,谢谢!
schooling_data = np.array(schooling_data)
# 对数据进行标记编码
label_encoder = []
X_encoded = np.empty(schooling_data.shape)
for i,item in enumerate(schooling_data[0]):
label_encoder.append(preprocessing.LabelEncoder())
X_encoded[:, i] = label_encoder[-1].fit_transform(schooling_data[:, i])
这是报错
D:/模式识别/儿童入学推荐.py:20: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
schooling_data = np.array(schooling_data)
Traceback (most recent call last):
File "D:/模式识别/儿童入学推荐.py", line 28, in <module>
X_encoded[:, i] = label_encoder[-1].fit_transform(schooling_data[:, i])
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed
一维的数组,却用了二维的方式来操作