statsmodel

[vagrant@localhost python]$ pip install statsmodels

import numpy as np 
import statsmodels.api as sm 
import matplotlib.pyplot as plt 

data = np.loadtxt("data.txt")
x = data.T[0]
y = data.T[1]

nsample = x.size 

X = np.column_stack((np.repeat(1, nsample), x))

model = sm.OLS(y, X)
results = model.fit()

print(results.summary())