Skip to content

Conversation

@robbertjan94
Copy link

@robbertjan94 robbertjan94 commented Feb 5, 2022

This PR fixes #77: implementing an excel renderer.

The excel renderer is based on the xlsxwriter package.

Example:

import pandas as pd
from sklearn import datasets
import statsmodels.api as sm
from stargazer.stargazer import Stargazer

diabetes = datasets.load_diabetes()
df = pd.DataFrame(diabetes.data)
df.columns = ['Age', 'Sex', 'BMI', 'ABP', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6']
df['target'] = diabetes.target

est = sm.OLS(endog=df['target'], exog=sm.add_constant(df[df.columns[0:4]])).fit()
est2 = sm.OLS(endog=df['target'], exog=sm.add_constant(df[df.columns[0:6]])).fit()
stargazer = Stargazer([est, est2])

Calling the excel renderer works similar to the html and LaTeX renderers:

stargazer.render_excel(filename='test.xlsx')

Which returns the following table in the test.xlsx file:

Table


if 'FOOTER' in location.name:
format1['bottom'] = 6
format1['bottom'] = 6
Copy link
Author

@robbertjan94 robbertjan94 Feb 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second format1 should be format2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to render as an excel file/pandas table

1 participant