【发布时间】:2020-07-03 03:19:52
【问题描述】:
我一直在关注这个 Python 线性回归教程:https://medium.com/@contactsunny/linear-regression-in-python-using-scikit-learn-f0f7b125a204
使用以下数据集: https://github.com/contactsunny/data-science-examples/blob/master/salaryData.csv
我的问题在于以下代码:
x = dataset.iloc[:, :-1].values
否定(-1)在这里做什么?如果我使用以下内容作为替代,为什么会出现错误:
x = dataset.iloc[:, 0].values
【问题讨论】:
-
-1 表示位置。在 dataset.iloc[:, :-1] 的情况下,表示获取除最后一列之外的所有列。
标签: python pandas machine-learning