Sharing code with Jupyter Notebooks

Posted February 6, 2020 | View revision history

This post is a follow-up to an earlier post about starting an online analytics portfolio, focusing on R. In that post, I walk though how to get markdown from an R script and share the static results with the internets.

A better way, with Jupyter Notebooks (.ipynb)

Been reading more about jupyter notebooks (.ipynb files).

  • They are not limited to python kernels – they can also run R.
  • The ipython tool nbconvert can convert them to a number of formats, including markdown and html.
  • Several places will nbconvert-them to html for you, including and github, gists, etc.
  • Under the hood, they are json. They save the results from when their code cells are run. Therefore, nbconvert does not need to execute the code cells. This means that notebooks that run specialized kernels or that need access to specialized environments such as ones from Amazon Sagemaker can be rendered using nbconvert anywhere.
  • jupyter notebooks can, obviously, be opened and run by jupyter, as long as jupyter has access to a compatible kernel and environment.
  • Several sites offer free cloud-based JupyterHub, which can let other people view and run jupyter notebooks, as long as the rendering service has a compatible kernel. These include but are not limited to:
    • Google Colab
      • .ipynb are saved to your google drive, and you can share them as you would other Google Drive documents
      • benefit is that you can point to a .ipynb that you have in Github, a Gist, or another git-like location
    • Kaggle
      • Notebooks live on Kaggle, and run Kaggle jupyter kernels.

David Eargle is an Assistant Professor at the University of Colorado Boulder in the Leeds School of Business. He earned his Ph.D. degree in Information Systems from the University of Pittsburgh. His research interests include human-computer interaction and information security. He has coauthored several articles in these areas using neurophysiological and other methodologies in outlets such as the Journal of the Association for Information Systems, the European Journal of Information Systems, the International Conference on Information Systems, and the Hawaii International Conference on System Sciences), along with the Proceedings of the ACM Conference on Human Factors in Computing Systems (CHI). More about the author →

This page is open source. Please help improve it.