这取决于您使用的api。如果您使用的是statsmodels.api,那么您需要通过在exog中添加一列1s来显式地将常量添加到模型中。如果你不这样做,就没有拦截。在import pandas as pd
import statsmodels.formula.api as smf
import statsmodels.api as sm
df = pd.DataFrame({'x': range(0,10)}).assign(y=lambda x: x+8)
# Fit y = B*x, no intercept
res1 = sm.OLS(endog=df.y, exog=df.x).fit()
==============================================================================
coef std err t P>|t| [0.025 0.975]
x 2.2632 0.269 8.421 0.000 1.655 2.871
============