In [1]:
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt # package for doing plotting (necessary for adding the line)
import statsmodels.formula.api as smf # package we'll be using for linear regression
In [3]:
df = pd.read_excel("data/2013_NYC_CD_MedianIncome_Recycle.xlsx")
df.head()
Out[3]:
In [4]:
def weight_predict(your_income):
df = pd.read_excel("data/2013_NYC_CD_MedianIncome_Recycle.xlsx")
lm = smf.ols(formula="RecycleRate~MdHHIncE",data=df).fit()
recycle_rate = your_income * lm.params.MdHHIncE + lm.params.Intercept
return recycle_rate
In [5]:
weight_predict(119596)
Out[5]:
In [ ]: