Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an excel renderer to the package #83

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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

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