In [12]:
import pandas as pd
import statsmodels.formula.api as smf
In [13]:
df = pd.read_excel("2013_NYC_CD_MedianIncome_Recycle.xlsx")
In [14]:
df.head()
Out[14]:
In [25]:
lm = smf.ols(formula="RecycleRate~MdHHIncE",data=df).fit()
intercept,slope = lm.params
def pre_weight(income):
recyclerate = intercept + income * slope
return recyclerate
In [26]:
pre_weight(2929292)
Out[26]:
In [ ]: