【发布时间】:2025-12-16 10:55:01
【问题描述】:
我正在使用 statsmodel 的 summary_col 给我一个输出表,它总结了两个回归输出。
代码是
res3 = summary_col([res1,res2],stars=True,float_format='%0.2f',
info_dict={'R2':lambda x: "{:.2f}".format(x.rsquared)})
f = open('res3.tex', 'w')
f.write(res3.as_latex())
f.close()
我使用 res3.tex 文件作为另一个 tex 文件的输入,然后生成结果。当我使用 as_latex() 将表格转换为 LaTeX 格式时出现问题。 The table header shifts to the side in the tex file and looks like this.
res3.tex 文件有以下乳胶代码
\begin{table}
\caption{}
\begin{center}
\begin{tabular}{lcc}
\hline
& investment I & investment II \\
\hline
\hline
\end{tabular}
\begin{tabular}{lll}
GDP & 1.35*** & 1.19*** \\
& (0.24) & (0.23) \\
bsent & 0.28*** & 0.26*** \\
& (0.06) & (0.06) \\
rate & -0.22* & -0.65*** \\
& (0.13) & (0.19) \\
research & & 0.80*** \\
& & (0.27) \\
R2 & 0.76 & 0.80 \\
\hline
\end{tabular}
\end{center}\end{table}
问题似乎是由于多个表格环境引起的。有没有办法在不手动更改 res3 文件(中间文件)的情况下将投资标头放在表的顶部?
【问题讨论】:
-
如果有人知道所需 Latex 的修复程序,那么 statsmodels 的问题或拉取请求会有所帮助。