Monday, January 4, 2016

Jupyter Notebooks

Happy New Year!

Let’s start off 2016 by learning something new: Jupyter Notebooks, formerly known as IPython Notebooks.

A Jupyter notebook is an interactive document that incorporates text, math, graphics, and code. It can be viewed in a Web browser. Unlike most documents, however, you can modify and execute the code inside the document. In this sense, a Jupyter notebook is similar to a session in Mathematica or Maple. The difference is that the interpreter running behind the scenes is not Mathematica or Maple. Jupyter notebooks were designed to run Julia, Python, and R, but they support over 40 languages at present.

The best way to learn about Jupyter notebooks is to take a look at one. This notebook is a simple example from a greenhorn, but you can find many more on the Web.

Introduction.ipynb

Click on the link to view the notebook. You can download the notebook using the Save icon at the upper right corner of the notebook Web page. You can then open the notebook, run it, and see the commands used to create it.

In my very limited experience, I find that notebooks are excellent for sharing code but not for developing code. An IDE like Spyder or working from the command line is more efficient for writing and debugging code, running scripts repeatedly, and generating complex graphics. However, once the scripts and modules are working properly, you can call them within a notebook.

Jupyter notebooks are great for exploring new ideas and solving problems. A Jupyter notebook allows you to integrate formatted text, mathematical formulas, Python code, and graphics into a single document. You can write about your ideas, do mathematical analyses, write and run code, view graphics, and reflect on the results without switching applications.

Even if you do not like to do all of your work on your laptop or in the computer lab — I still prefer pencil and paper for many tasks — Jupyter notebooks are a great option for writing up your work and sharing it with others. A Jupyter notebook is like a word processor that can also run Python code. You can keep detailed notes with working code for your own personal files. You can write up homework assignments. You can write reports to share your work with other scientists. You can publish your work on the Web. (The procedure for sharing a notebook over the Internet can be found here.) A notebook can be exported in several formats, including HTML. If you have LaTeX installed on your system, you can also convert the notebook to a PDF file.

If you would like to see more examples of notebooks, explore this gallery. Enjoy!

No comments:

Post a Comment

Thank you for your input!
To avoid duplication, spam, and inappropriate content, we will review comments before posting them.


— Jesse & Phil