Jupyter Rising

Getting started with Jupyter notebooksJupyter notebooks provide a great way to create demos, document reproducible research, and provide educational content. They make code come to life by displaying the results of the program that is being executed. J…


This content originally appeared on Level Up Coding - Medium and was authored by Dimitri Papaioannou

Getting started with Jupyter notebooks

Jupyter notebooks provide a great way to create demos, document reproducible research, and provide educational content. They make code come to life by displaying the results of the program that is being executed. Jupyter notebooks tell a story, and their interactive features let the user participate in it.

This article is for anyone interested in getting started with Jupyter notebooks. No Python experience is required.

Install Anaconda

Jupyter notebooks require Python to run. For this article, I will use a python toolbox and package manager called Anaconda. It can be installed from this site: https://www.anaconda.com/.

Once Anaconda is installed, you will have access to the command line utilities. If you are using a mac, they will be integrated in the normal terminal window. If you are using Windows, there will be an “Anaconda Prompt” terminal window. Alternatively, if you’d rather open it in Powershell, you can follow the instructions in this article: Anaconda on the Windows Powershell.

Create an environment

A recommended python programming practice is to create a virtual environment for each project. A virtual environment keeps dependencies required for a project isolated from other projects.

Let’s create an environment called “jupyter-rising.” Open the Anaconda shell and type


conda create -n jupyter-rising

The output will look like this:

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate jupyter-rising
#
# To deactivate an active environment, use
#
# $ conda deactivate
Retrieving notices: …working… done

Follow the advice and activate the environment


conda activate jupyter-rising

Once you activate the environment, every library you install will be for that environment only.

Install and enable Jupyter

Having activated the environment, you can now install jupyter

conda install jupyter

The next step is to install a kernel. Kernels are like Anaconda environments for jupyter. They allow different projects to access different features nut unlike conda, where every environment is inPython, jupyter kernels can be in a number of supported programming language. A list of supported kernels can be found here.


ipython kernel install --name "jupyter-rising" --user

Now start a jupyter notebook..

jupyter notebook

A browser window will open at the address http://localhost:8888/tree displaying the contents of the current directory. Click “New” on the upper right-hand corner and select the “jupyter-rising” kernel.

Getting started with Jupyter

I will not attempt to cover the abilities of Jupyter notebooks in any detail. Luckily, there are countless of online resources for that. I will only demonstrate, very briefly, the most common feature that I use.

Interactive Programming

Enter the following code in the notebook

a = 4
b = 1+2j
a+b

When you click “Run”, the notebook will execute the code, display the result, and open another cell.

Markdown documents

In the next cell, go to the dropdown on the menu and switch from “Code” to “Markdown”. This setting is for writing text in text instead of code. Write for example:

# This is a Heading
## A subheading
### and so on

This is normal text

When you click “Run”, the result will be formatted text:

Latex Rendering

Jupyter comes with built-in support for LaTex equation formatting. In the next cell, choose “Markdown” again, and write

$E = mc^2$

Click run to see the rendered equation:

Sharing Jupyter notebooks

  • GitHub is a popular source code repository for collaborating on projects. Github provides a rudimentary viewer for notebooks when you click on one. See for example https://github.com/algorythmist/finance-toolbox/blob/main/notebooks/cppi-demo.ipynb
  • At the time of this writing, GitHub does not provide interactive features and its latex rending is buggy. To share a notebook with interactive features you can use nbviewer. S
  • Google colab provides the ability to create and share online notebooks on the Google server, including the option to run on a CPU or GPU. It requires a google email account and offers paid versions that give you access to more computational power.
  • Kaggle is an online platform for Machine Learning competitions. It provides a huge wealth of clean dataset and a ton of resources for ML students and practitioners. It also provides its own implementation of online Jupyter notebooks. The look and feel of these notebooks is different, but the functionality is pretty much the same.

Jupyter Rising was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Level Up Coding - Medium and was authored by Dimitri Papaioannou


Print Share Comment Cite Upload Translate Updates
APA

Dimitri Papaioannou | Sciencx (2022-12-06T12:37:46+00:00) Jupyter Rising. Retrieved from https://www.scien.cx/2022/12/06/jupyter-rising/

MLA
" » Jupyter Rising." Dimitri Papaioannou | Sciencx - Tuesday December 6, 2022, https://www.scien.cx/2022/12/06/jupyter-rising/
HARVARD
Dimitri Papaioannou | Sciencx Tuesday December 6, 2022 » Jupyter Rising., viewed ,<https://www.scien.cx/2022/12/06/jupyter-rising/>
VANCOUVER
Dimitri Papaioannou | Sciencx - » Jupyter Rising. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/12/06/jupyter-rising/
CHICAGO
" » Jupyter Rising." Dimitri Papaioannou | Sciencx - Accessed . https://www.scien.cx/2022/12/06/jupyter-rising/
IEEE
" » Jupyter Rising." Dimitri Papaioannou | Sciencx [Online]. Available: https://www.scien.cx/2022/12/06/jupyter-rising/. [Accessed: ]
rf:citation
» Jupyter Rising | Dimitri Papaioannou | Sciencx | https://www.scien.cx/2022/12/06/jupyter-rising/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.