Another Reason to start using Jupyter Notebooks

Osama Ahmad
4 min readNov 6, 2023

For many people who still might not be using Jupyter Notebook or do use it, a surprise is coming your way. As we all know, it’s pretty good to work in Jupyter Notebooks, but if you were to export it in HTML or a PDF, it is a nightmare.

If I were to convert the following jupyter notebook to HTML,

Jupyter Notebook Code

This is how it comes out.

Output of Above code

It does the job, if you ask me. Not many options for formatting, just simple good ol’ Jupyter Notebook slapped into HTML format for user.

But That has changed. As I got my hands on a tool that is used to transforms simple jupyter notebooks to formatted and nothing less of amazing notebooks.

Introducing Quarto

Quarto

Quarto supports multiple languages like Python, R, Julia and Observable. This tool can completely change the look and functionality of your Jupyter notebooks but with less headaches or things to remember or even many new tools to install.

I got an Email from Data Elixir (subscribe to this newsletter, it’s very insightful), I was scrolling through to see what’s new in Data Science field and I come across this tool called Quarto.

It was new to me in general as I had never heard of this before, but the email was about the announcement of Dashboards coming to Quarto.Dashboards in Jupyter Notebooks?” I thought to myself, “that’s cool”. I went to the home page and what I found would change things for better.

Quarto offered a lot more than just dashboards. I was very happy and surprised as I started to look more and more on this website and the things this tool offered. I thought of trying this myself and so I did. The results made me very glad to have found Quarto.

From simply making your Jupyter Notebook better to Dynamic Documents, Quarto is killing it (Read more here).

Using Quarto

I have had a lot of problems with converting my Jupyter Notebooks to different formats and the results were always sub-par.

Here are some before and afters of the HTML pages from my website;

Altair: First Chart Tutorial
Fayetteville Arrests by Hours Histogram

Now I think you understand why I’m speaking so highly of Quarto. You can use this tool to create your jupyter notebook not just amazing looks wise but also add functionality to them and using them to showcase your notebook projects however you want, in docx, pdf, html .etc.

Let’s Change one Together!

Let me show you how easy it is to do. Let’s convert this notebook.

Jupyter Notebook Code

You make the first block of code of notebook ‘Raw’ type and use the following;

---
title: "This is the title of this Jupyter Notebook"
format:
html:
code-fold: true
jupyter: python3
---

Break down:

  • ‘title’ - Pass the Title of the Notebook to this argument,
  • ‘format’ - Pass the format of your notebook, here I pass ‘html’,
  • ‘html’ - Passing the ‘code-fold: true’ means that code blocks will be folded by default, other information can be passed here as well,
  • Lastly, ‘jupyter’ - Passing language of Notebook here ‘Python’.

Like so,

Changing the Block

Previously it was;

Jupyter HTML Export

Here’s the result using Quarto;

Quarto Used notebook

As you can see, the latter picture contains more formatting and better aesthetics as compared to other notebook, just by very less effort.

I would encourage you to take a look for yourself (here) and use this amazing tool to your advantage in everyday Data Science work.

Until next time, stay safe Dear friends.

--

--