我认为应该这样做。
#First generate the data
x=pd.DataFrame(np.random.randn(10,1))
y=pd.DataFrame(np.random.randn(10,4))
#Since we are doing things manually we'll need to add the constant term to the x matrix
x[1] = ones(10)
#This matrix precomputes (X'X)^-1X which we will premultiply the y matrix by to get results
tmpmat = np.dot(np.linalg.pinv(np.dot(x.T ,x)),x.T)
#Solve for the betas
betamatrix = np.dot(tmpmat,y)
#Compare with the pandas output one at a time.
model=pd.ols(y=y[0], x=x, intercept=False)
model=pd.ols(y=y[1], x=x, intercept=False)