python - 将回归结果从 python statsmodel 打印到 Excel 工作表中

标签 python statistics export-to-excel statsmodels

我的工作需要对不同类型的数据运行多次回归,然后需要在演示文稿中呈现这些结果 - 我使用 Powerpoint,它们可以很好地链接到我的 Excel 对象,例如图表和表格

有没有办法将结果打印到现有工作表中的一组特定单元格中?

import statsmodels.api as sm
model = sm.OLS(y,x)
results = model.fit()

例如,想要将回归 result.params 发送到 B 列。有什么想法吗?

非常感谢。

最佳答案

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')

关于python - 将回归结果从 python statsmodel 打印到 Excel 工作表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28843441/

相关文章:

python - 初始化驱动程序时 Selenium 连接超时

mysql - 在 MySQL 中计算平均意见得分 (MOS)

PHP 驱动的详尽统计数据 - 服务器端文本文件或 MySQL 表?

export-to-excel - 将超过 100000 行导出到 Excel - Infragistics Excel 导出器

asp.net - 将 MS 图表导出为 PDF 和 Excel

java - Excel在循环过程中的列分布行为,可能吗?

Python如何在列表中搜索给定输入的所有排列?

python - 使用 `timeit` 的 60MB 字符串测试加入列表会导致 MemoryError

python - 查找日期列表中的日期差异 [Pandas]

c# - 在 C# 中计算中值绝对偏差