This post explains how to generate management-quality PDF or HTML reporting directly from Jupyter Notebook. With this technique, I reduced to zero the most irritating part of my projects: copy-pasting diagrams into PowerPoint.

The workbook pasted below demonstrates how this can be done.

shared-kernel-B


I hate writing reports

I hate reporting. I love creative research and discovering truth in data. But then the process of collecting the facts into a document or presentation is dull and boring. The worst part comes when diagrams need to be copied in PowerPoint. If I spot an error in the diagram, I need to generate it again and paste again.

Over the past week I had some fun analyzing the client’s historical data. The final PowerPoint was rich with details: project health analysis, predictive analytics, anomaly detection, workload allocation, automation analysis, trends analysis, and so on. The client appreciated the results and asked whether I could run similar analysis on five other projects. I could, but the perspective of copy-pasting one hundred diagrams into five more PowerPoints was dreadful.

Then I thought, couldn’t I possibly generate the final report directly from JupyterLab Notebook?


Why not simply save the notebook as PDF?

Notebooks can be exported as PDF, webPDF or HTML, using File / Export Notebook As menu option.
So in principle, with some discipline and keeping the notebook tidy, you could organize the notebook in such a way that it serves as the final report.

But my notebooks document my research process and their structure is not suitable to the audience of my end reports: managers, who are not interested in my thought process, neither in the source code, but the business conclusions.

So it would be optimal to maintain two notebooks. One to document the research process, and the other for the reporting. I found a simple and efficient way for this.


Ultimate solution: share kernel between two notebooks

Below is the content of my research notebook A. It contains some code, which I don’t want the business users to see. It defines some methods and variables. Then, after the work is done, I generate all diagrams in the workbook B, which you have already seen above. The only trick is to share the Jupyter kernel between the both.

shared-kernel-A