Meaning of X = X[:, 1] in Python

后端 未结 3 478
长情又很酷
长情又很酷 2021-01-31 09:41

I am studying this snippet of python code. What does X = X[:, 1] mean in last line?

def linreg(X,Y):
    # Running the linear regression
    X = sm.         


        
3条回答
  •  青春惊慌失措
    2021-01-31 10:08

    it is simply like you are specifying the axis. Consider the starting column as 0 then as you go through 1,2 and so on.

    The syntax is x[row_index,column_index]

    you can also specify a range of row values as per need in row_index also eg:1:13 extracts first 13 rows along with whatever specified in column

提交回复
热议问题