Graphical outputs such as charts will also appear.
We don’t need to worry about page sizes since we have plenty of rows and columns to fill if the notebook is long or wide.
nb2xls screenshotTo install, just run pip install nb2xls and this should add an extra ‘Download As’ option in the File menu: ‘Excel Spreadsheet (.
It’s an experimental package at the time of writing — the code still needs some work to produce the best results for complex tables or markdown.
Please give it a try with your own notebooks, and get in touch if there are any improvements to be made (please send example ipynb files where possible).
More details and examples are on GitHub here.
Converting on the Command LineAll these ‘Download As’ options are really just wrappers for the command-line utility nbconvert, invoking the conversion process with the default options.
The command line equivalent can be good to know if you do need to specify any conversion options.
For example, the Hide Input All extension documentation suggests the following command to obtain an exported HTML file with input code cells removed:jupyter nbconvert –template=nbextensions –to=html my_notebook.
ipynbSave files yourself!The ‘Download As’ options provide some useful infrastructure for exporting the skeleton of your notebook to a separate file.
But it’s worth remembering that you are already in your familiar coding environment, so it might make sense to produce some files directly from a code cell.
For example, if you have a large Pandas DataFrame, the best thing might be to save it as a CSV so it can be loaded by your recipient in its entirety.
Something like this: df.
In practice, you’ll want to import this into Excel first so you can format the columns and underline the headings etc.
When you can’t escape from JupyterWhile the export options above just about allow you to obtain the crux of your notebook in a standalone file format, sometimes (especially where widgets feature heavily in your notebook) you need to find a way to stick with your existing Jupyter format.
But you need to find a way to share it with your non-developers such that it:makes sense to themis easy to accessis secure so sensitive data cannot be seen outside your organisationis safe so that non-developers can’t break anything or destroy any dataThe rest of this article uncovers some possible approaches to this.
Jupyter’s own projectsThe Project Jupyter organisation has some auxiliary projects that might be considered if you need to share notebooks frequently enough that it’s worth investing in some infrastructure.
The Two HubsJupyterHub is a way to centralise the creation of Jupyter workspaces on shared resources, so at least other users will not need to run their own Jupyter servers.
Unless you have a small organisation that can run JupyterHub on an internal network, you will need to consider how to add authentication for the appropriate users.
There are some suggestions here as to how you might share notebooks within different users’ workspaces.
Logo on the JupyterHub homepageBinderHub really extends JupyterHub by allowing a user to launch a Jupyter workspace based on a specific computing environment (Python packages etc) which is defined within a git repository along with the data files and notebooks relevant to the project.
The user can launch the workspace by accessing a single URL directly.
This allows a much more formalised and easy-to-access showcase for your work.
To see an example on the public instance of BinderHub known as mybinder.
org, check out the ‘Launch Binder’ link on the Readme page of my nb2xls repo on GitHub.
In practice, both of these projects aren’t suitable for our task out-of-the-box— the management team don’t want to have to shift-enter their way through a notebook!.And storing work in a git repo or workspace, such that it makes sense to a non-developer, is a lot of administrative overhead.
nbviewernbviewer is a much more suitable and lightweight service for easy hosting of notebooks through a single URL.
As with Binder, there is a free hosted version of nbviewer for you to try out.
Typically, you provide the URL to a notebook on GitHub, but it can also work with a Dropbox link.
For example, ‘Copy Dropbox Link’ on an ipynb file in Dropbox, then paste the URL into the box on https://nbviewer.
You can share the resulting viewer page’s URL with your colleagues, but of course note that this is not secure.
org homepageSharing a URL is more likely to feel natural than emailing an HTML file to your management team, but really you’re not going to get much from nbviewer that you couldn’t achieve with the HTML export.
So none of the major Project Jupyter initiatives appear to help us much so far…There it is!A recent development from Project Jupyter might be just what we’re looking for: voilà allows you to host a notebook with a live kernel without any shift-entering required.
By default, code cells are hidden.
And by default execute requests from the front-end are disallowed, so the user can’t break anything even if they tried!The Jupyter blog post announcing voilà does a great job of describing the problem they’re trying to solve (which is exactly the one we’re discussing!) and explains some of the features.
voilà logoThis could become a fantastic way to share your notebooks in the situations we’re discussing, but it still needs a lot of work.
At the time of writing, you can only share a single-user link to the notebook-application, and multiple users could clash if their independent actions manage to confuse the flow of data in your notebook.
Plans are already in place to integrate voilà with JupyterHub (mentioned above) which should allow multiuser access to your voilà-hosted notebooks.
Of course you would still need to be sure the voilà server is running whenever your colleagues choose to look at your notebook, so this isn’t something you would typically keep running on your local machine.
Looking Further AfieldKyso is a third-party service allowing you to ‘blog your data science’.
There are public notebooks (as well as articles, links, datasets, and charts) listed on their homepage that should give you some idea how notebooks can be shared On the paid plan you can restrict collaboration to within your team.
Code input cells are hidden by default!It should be possible to include live Jupyter widgets although right now I run into problems due to the fact that JupyterLab isn’t fully stable and many Jupyter widgets aren’t yet adapted for JupyterLab.
Kyso seems to be fixed on JupyterLab 0.
35 at the moment.
Please reach out to their sales team for more details on functionality if you think a third-party service like this could work for you.
Kyso homepage showing some public notebooksAnother service, Saturn Cloud is a full cloud hosting environment for your data science, as an alternative to Google Cloud or AWS etc, with ‘publish’ functionality built in.
While your colleagues could easily launch your notebooks, it doesn’t appear that fully-private publication is possible.
I’m sure there are others.
Please let us know in the comments if you’ve used a third-party service to solve this problem.
ConclusionIt turned out to be harder than we hoped to share the results of our Jupyter Notebook experiments with non-developers!.The features we wanted were to ensure code is hidden, the results are easy to access, the display is as interactive as needed, and our data is kept safe and secure.
Although some export functionality is now available (HTML, PDFs, Excel spreadsheets), these all present challenges or limitations where complex data is to be shared.
And looking at the more substantial hosted options, we either need to implement our own infrastructure (e.
running our own nbviewer or voilà instances) or rework our data science workflow into a new third party cloud hosting service.
So the best solution will depend heavily on the data you’re sharing, and how often you need to present similar reports.
It’s worth looking out for patterns in the kinds of presentations made throughout your organization.
For ad-hoc sharing of large data analyses you might still need to assemble your own spreadsheets from carefully exported CSVs; but if this happens a lot it might be time to invest in some reusable infrastructure to solve this problem.