Package: reportlib
reportlibFlexible and powerful report library for Python or Python Notebooks withPandasandJinja2supportLatest ReleaseLicensePython VersionWheelWhat is it?reportlibis a Python package providing fast and flexible utilities to decorate and render a report. Because it based on pandas's Styler, it is friendly with pandas DataFrame, so if you got your data, you can easily display and export it.Main FeaturesHere are just a few of the things that reportlib does well:Powerful and flexible Styler based onpandas's Styler, friendly with pandas DataFrame, with more styling methodsFriendly with Email: The HTML output use inline-css, you can send via email and that email also can be forwardedFriendly with Python Notebooks, so you can display Styler or Report in htmlConfig parser: from string to other data types, for quickly get config from environment or other config filesCustomize everything withJinja2support: table head & foot (Styler), Report template, cssWhere to get itThe source code is currently hosted on Teko's Gitlab at:https://git.teko.vn/data/libs/reportlibBinary installers for the latest released version are available at thePython package indexpip install reportlibDependencies:css-html-js-minify: 2.5 or higherhtmlmin: 0.1 or higherJinja2: 2.10 or higherpandas: 0.24 or higherpython-dateutil: 2.8 or higherPyYAML: 5.1 or higherpremailer: 3.5 or higherInstallation from sources:Clone the repository then execute following command in thereportlibdirectory (same one where you found this file after cloning the git repo)python setup.py installAlternatively, you can use pip if you want all the dependencies pulled in automatically (the -e option is for installing it in development mode):pip install -e .Basic usageProject structureroot/ (or root/src/)
 |-+-templates/
 | |-styles.css
 |-report.py
 |-metadata.yml
 ...Config reportexportREPORT_DATE='2019-06-30'Render report"""report.py"""importosimportpandasaspdimportnumpyasnpfromdatetimeimportdatetimefromdateutil.relativedeltaimportrelativedeltaimportreportlibfromreportlibimportReport,ConfigParser,Styler# Parse config from envconfig=ConfigParser(config=os.environ)report_date=config.date('REPORT_DATE',default='yesterday')# Prepare datadf=pd.DataFrame(np.random.randn(8,4),columns=['a','b','c','d'])# Config reportreportlib.add_template_dir('templates')Styler.set_option('precision',2)Styler.set_option('fillna','-')Styler.set_option('fillinf','-')Styler.set_option('fillzero','-')# Initial generatorreport=Report(styles='styles.css',title='Report Demo',context={'report_date':report_date},)# Styling datastyle=(Styler(df).add_class('bold highlight',subset=pd.IndexSlice[0:1,df.columns])# Bold and Highlight some row by using class `highlight`.add_class('text-right',columns=df.columns)# Align right columns)# Add tablesreport.add_table(style)# Run reporthtml_string=report.render()# Or display it if you use a Python Notebook Interface like Jupyterreport.show()Full DocumentationYou can found full documentation inWikiGetting HelpFor usage questions, the best place to go to isFull Documentation. Further, for general questions and discussions, you cancreate an issueor contact me via email atnhat.nv@teko.vnor viaTeko's workplaceContributing to reportlibAll contributions, bug reports, bug fixes, documentation improvements, enhancements and ideas are welcome.