7
我正在研究Python代碼片段。 X = X[:, 1]
在最後一行是什麼意思?Python中X = X [:,1]的含義
def linreg(X,Y):
# Running the linear regression
X = sm.add_constant(X)
model = regression.linear_model.OLS(Y, X).fit()
a = model.params[0]
b = model.params[1]
X = X[:, 1]
多謝了Leb – Taewan
沒問題,很高興我的幫助。 – Leb
您的鏈接不正確(它指向Python 2.3文檔)。改用'numpy'文檔中的[this one](http://docs.scipy.org/doc/numpy-1.10.1/reference/arrays.indexing.html#basic-slicing-and-indexing)。 – MattDMo