Data

Introducing Jupytext: Jupyter notebooks as Markdown documents, Julia, Python or R scripts

2 min read

Project Jupyter released Jupytext, last week, a new project which allows you to convert Jupyter notebooks to and from Julia, Python or R scripts (extensions .jl, .py and .R), markdown documents (extension .md), or R Markdown documents (extension .Rmd). It comes with features such as writing notebooks as plain text, paired notebooks, command line conversion, and round-trip conversion.

It is available from within Jupyter. It allows you to work as you would usually do on your notebook in Jupyter, and save and read it in the formats you select.

Let’s have a look at its major features. 

Writing notebooks as plain text

Jupytext allows plain scripts that you can draft and test in your favorite IDE and open naturally as notebooks in Jupyter. You can run the notebook in Jupyter for generating output, associating a .ipynb representation, along with saving and sharing your research.

Paired Notebooks

Paired notebooks let you store a .ipynb file alongside the text-only version. Paired notebooks can be enabled by adding a jupytext_formats entry to the notebook metadata with Edit/Edit Notebook Metadata in Jupyter’s menu.

On saving the notebook, both the Jupyter notebook and the python scripts are updated.

Command line conversion

There’s a jupytext script present for command line conversion between the various notebook extensions:

jupytext notebook.ipynb –to md –test      (Test round-trip conversion)

jupytext notebook.ipynb –to md –output      (display the markdown version on screen)

jupytext notebook.ipynb –to markdown           (create a notebook.md file)

jupytext notebook.ipynb –to python               (create a notebook.py file)

jupytext notebook.md –to notebook              (overwrite notebook.ipynb) (remove outputs)

Round-trip conversion

Round-trip conversion is also possible with Jupytext. Converting Script to Jupyter notebook to script again is identity, meaning that on associating a Jupyter kernel with your notebook, the information will go to a yaml header at the top of your script. Converting Markdown to Jupyter notebook to Markdown is again identity.

Converting Jupyter to script, then back to Jupyter preserves source and metadata.

Similarly, converting Jupyter to Markdown, and Jupyter again preserves source and metadata (cell metadata available only for R Markdown).

For more information on, check out the official release notes.

Read Next

10 reasons why data scientists love Jupyter notebooks

Is JupyterLab all set to phase out Jupyter Notebooks?

How everyone at Netflix uses Jupyter notebooks from data scientists, machine learning engineers, to data analysts

Natasha Mathur

Tech writer at the Packt Hub. Dreamer, book nerd, lover of scented candles, karaoke, and Gilmore Girls.

Share
Published by
Natasha Mathur
Tags: AI News

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago