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

后端 未结 3 449
长情又很酷
长情又很酷 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 09:51

    Something you shoud know

    The term you need to search for is slice. x[start:end:step] is the full form, Here we can omit to use a default value: start defaults to 0 , end defaults to the length of the list, and step defaults to 1. And hence x[:] means same as x[0:len(x):1]

提交回复
热议问题