Why do you set 1 as intercept in linear regression model in python? I'm learning linear regression in Udacity as a beginner. I know statsmodels.regression.linear_model.OLS() needs an intercept but why do you set 1 as intercept?
Even though we set that value, the fit result shows different values as the intercept.
Then what does setting 1 mean? Also do we usually use 1 for this setting?
 A: I don't know the python function/method you are referring to. But you may be confusing that the 1 you add is to your variables/feature such that it is multiplied by the intercept parameter in your parameter vector. In other words, 1 is rather added to your features and is NOT the value of your intercept.
A: I do not know Python, but as you can readily illustrate in R, setting the value of the intercept to 1 is really just a convention (a useful one, though, of course, allowing us to interpret the intercept as the expected effect when $x=0$).
n <- 10
y <- rnorm(n)             # some random data
x <- rnorm(n)
intercept <- rep(1,n)     # a "hand-made" intercept

lm(y~x)                   # the default in R which includes an intercept
lm(y~intercept+x-1)       # removing the default intercept with -1 and re-adding it manually as another regressor
lm(y~I(2*intercept)+x-1)  # removing the default intercept with -1 and re-adding 2 as a constant term

Output:
> lm(y~x)

Call:
lm(formula = y ~ x)

Coefficients:
(Intercept)            x  
   -0.07813      0.55086  


> lm(y~intercept+x-1)

Call:
lm(formula = y ~ intercept + x - 1)

Coefficients:
intercept          x  
 -0.07813    0.55086  


> lm(y~I(2*intercept)+x-1)

Call:
lm(formula = y ~ I(2 * intercept) + x - 1)

Coefficients:
I(2 * intercept)                 x  
        -0.03907           0.55086 

As you can see, the first two regressions are exactly the same (as fully expected), and the third has the same coefficient on x, and exactly half the coefficient on the constant term, to account for the effect that we have multiplied that by two.
