Reputation: 11
My job requires running several regressions on different types of data and then need to present these results on a presentation - I use Powerpoint and they link very well to my Excel objects such as charts and tables
Is there a way to print the results into a specific set of cells in an existing worksheet?
import statsmodels.api as sm
model = sm.OLS(y,x)
results = model.fit()
Would like to send the regression result.params into column B for example. Any ideas?
Thanks very much.
Upvotes: 1
Views: 9336
Reputation: 8281
import pandas as pd
import statsmodels.api as sm
dta = sm.datasets.longley.load_pandas()
dta.exog['constant'] = 1
res = sm.OLS(dta.endog, dta.exog).fit()
df = pd.concat((res.params, res.tvalues), axis=1)
df.rename(columns={0: 'beta', 1: 't'}).to_excel('output.xls', 'sheet1')
Upvotes: 2