Skip to content

Instantly share code, notes, and snippets.

@ewalk153
Created August 9, 2015 16:16
Show Gist options
  • Save ewalk153/4782b2c4b9e50638e2be to your computer and use it in GitHub Desktop.
Save ewalk153/4782b2c4b9e50638e2be to your computer and use it in GitHub Desktop.
# http://stackoverflow.com/questions/19991445/run-an-ols-regression-with-pandas-data-frame
import pandas as pd
import statsmodels.formula.api as sm
df = pd.DataFrame({"A": [10,20,30,40,50], "B": [20, 30, 10, 40, 50], "C": [32, 234, 23, 23, 42523]})
result = sm.ols(formula="A ~ B + C", data=df).fit()
print result.params
print result.summary()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment