python - Is there a way to automate the presentation of pandas Dataframes in an attractive manner -
an important component of job presenting data tables in attractive manner. lot of work in pandas , have export excel , work on presentation in there. know of way present pandas data frames in attractive looking tables?
i approach @brandon rhodes takes in excellent pandas tutorial. uses ipython notebook, , @ beginning of notebooks, adds lines:
from ipython.core.display import html css = open('style-table.css').read() + open('style-notebook.css').read() html('<style>{}</style>'.format(css))
which references files style-notebook.css
, style-table.css
in project directory. files (which can found on github page) can modified like, here's like.
style-notebook.css:
h3 { color: white; background-color: black; padding: 0.5em; }
style-table.css:
body { margin: 0; font-family: helvetica; } table.dataframe { border-collapse: collapse; border: none; } table.dataframe tr { border: none; } table.dataframe td, table.dataframe th { margin: 0; border: 1px solid white; padding-left: 0.25em; padding-right: 0.25em; } table.dataframe th:not(:empty) { background-color: #fec; text-align: left; font-weight: normal; } table.dataframe tr:nth-child(2) th:empty { border-left: none; border-right: 1px dashed #888; } table.dataframe td { border: 2px solid #ccf; background-color: #f4f4ff; }
the resulting tables nice; example:
Comments
Post a Comment