LOST-STATS/lost-stats.github.io

how to save the stargazer output table into a file/png using Python

yangyijane opened this issue · 1 comments

Hi I have used Python package stargazer to generate a nice table to showcase all the regression output in html format.
I am wondering how shall I save this format into a certain folder so that I could share it with my co-authors?

Hi @yangyijane, you can find an example of saving it to a latex file here: https://aeturrell.github.io/coding-for-economists/auto-research-outputs.html#tables

To turn reg_results from that example into HTML, it's reg_results.render_html(). If you want that saved, something like

with open('reg_table.html', 'w') as f:
    f.write(reg_results.render_html())

should work.

If you want to share a jupyter notebook, you should just be able to type reg_results in a cell and it will auto-display (including when you export the notebook to html).