Jupyter Notebooks are The Business

Ryan Palo - Jun 14 '17 - - Dev Community

So this is about one of those things that I knew existed, but I kind of thought "Oh, this is just for scientists and data people to do science and data things." And then I used it to write interactive code snippets for a lecture (that I hope to give some day) and now my mind is blown and I'm probably going to write all of my blog posts this way from now on. So without further ado:

Jupyter Notebooks

You may know about these. If you're a data scientist or have done some amount of Python you may have seen these, and you may know it by its previous name: IPython Notebooks. For those of you who don't know, it looks like this.

first look at Jupyter Notebook

It's awesome. It has individual cells that can be code or markdown. The code cells run independently, but in the same namespace, so you can carry variables and data from one cell to the next. You can do something like this:

notebook cell demonstration

Note how the cells will output the last evaluation without a print statement required, just like a REPL. Here are some other cool things.

Pretty Data Output

If you are working with a lot of data, notebooks will inline pretty table and chart outputs.

different cell outputs

Internal Links

This:

Raw table of contents

Renders to this:

Rendered table of contents

And the internal links work!

No More Cleanup Scripts

Again, if you're working with data, you don't have to have a separate script to clean the data and re-output it into a csv (or whatever). Each cell remembers its state, so you can run the cell at the top that takes forever to clean the data once and then re-run and re-modify the cells below without having to rerun the cleaning cell.

Lots of Inputs and Outputs

While I found out about it through Python -- and I think initially it only supported Python -- the community now provides about a billion different kernels you can run. See the full list here.

For my purposes, I like that it outputs directly to markdown for blog posts, but it also outputs into Python files, ReSTructured text, LaTex, PDF, and HTML!

More

I also just discovered something called nbgrader that is essentially an assignment/automated grading framework for Jupyter Notebooks. I haven't used it yet, but it looks like the things that dreams are made of. There's also support for converting a notebook into a html slideshow. This plugin allows for a powerpoint-like feel while still being able to execute cells, for prestructured quasi-live-coding demos. Honestly, as I keep finding these features, I keep getting more and more excited.

I'm really interested in seeing if I could use this even more in a classroom setting. If you are using Notebooks in the classroom, let me know about it! Also, let me know all about everything you do for teaching because teaching coding in the classroom is currently my dream goal.

Long story short, Jupyter Notebooks are The Business. Get them today.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .