【发布时间】:2018-12-26 17:57:58
【问题描述】:
这是我的代码:
y_predForThisMatchType = model.predict(X_test, num_iteration=model.best_iteration)
print(type(y_predForThisMatchType))
y_predForThisMatchType = y_predForThisMatchType.reshape(-1)
print(type(y_predForThisMatchType))
count = 0
for i in range (len(y_pred)):
if y_pred.loc[i] == abType:
y_pred.loc[i] = y_predForThisMatchType[count]
count = count + 1
输出:
类'numpy.ndarray'
类'numpy.ndarray'
/opt/conda/lib/python3.6/site-packages/pandas/core/indexing.py:189:SettingWithCopyWarning:
试图在数据帧的切片副本上设置值
请参阅文档中的注意事项:http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy self._setitem_with_indexer(indexer, value)
Python 只是打印上面的输出,仅此而已。该程序在技术上正在运行,但下面的代码没有被执行,没有显示真正的错误。
错误行:
y_pred.loc[i] = y_predForThisMatchType[count]
y_pred 变量是 pandas 数据框。
【问题讨论】: