♦ Step 1: Activate your Jupyter environment

This should bring you to your personal Jupyter environment, where you can write and execute your own Python code. When you close your browser, this environment stays active and you can return to your work in progress by going back to the link above.

You'll see in your Jupyter environment some menus and a list of .ipynb documents.

Note: Some Jupyter containers are now defaulting to "Jupyter Lab", which is slightly different than "Jupyter Notebooks". To make sure you have Jupyter Notebooks running, look at the web address: if it ends in /lab, then just delete the /lab and the page will reload to Jupyter notebooks, where the web address ends in /tree.

♦ Step 2. Uploading course materials to your environment

The Jupyter notebooks we'll use for today's lesson reside on a remote GitHub repository. GitHub is another valuable tool in the Data Analytics world that we don't have time to dig into right now. However, we will use it to 'clone' the files we need to our Jupyter machine.

To do this we need to run a shell command, which is done in new a Jupyter notebook linked not with the Python kernel, but with the "Bash" linux kernel.

  • From the Jupyter environment's home page, select the New menu dropdown and choose, Bash.
  • Type the following command in the first box:
    git clone https://github.com/DataDevils/WaterFlow-Python.git Clone image
  • Execute the command as before by hitting the ►| button. As this runs you'll see status messages that the 'WaterFlow-Python' is being downloaded.
  • Close and halt your newly created Bash notebook. It will be called untitled.ipynb in your Jupyter environment.
  • You should also see in your Jupyter environment a new folder named WaterFlow-Python.

What is this Jupyter environment thingy?

No time to go into great detail, but your Jupyter environment is a touch like a file system in that it lists the files in your workspace and allows you to open and manage them. What's important to us right now is that this Jupyter environment where you can create Jupyter Notebooks.

What is a Jupyter Notebook?

For us, here, today, a Jupyter notebook is where we'll write and execute our Python code.

Jupyter notebooks can do more, a lot more, than just run Python code, but again, that's not our focus here. So we'll distill it down to this:

  • A Jupyter notebook can contain both rich text (formatted, with figures, formulas, plots, etc.) AND executable code.
  • Each notebook is associated with a kernel, or an engine for executing code. We'll be using the Python 3 kernel, but you can actually write Jupyter notebooks that run R by associating it with an R kernel.

The documents you see with the .ipynb extension are all Jupyter notebooks. The extension is actually short for iPython notebook, as Jupyter evolved from interactive Python, or iPython for short.

There's much more to these notebooks, more than we can cover in a day, let alone a few minutes, so we'll learn what we need as we go. Plenty of more comprehensive introduction to the Jupyter environment and Jupyter notebooks are on line. Some examples:


Exercise 0.1: Navigating a Jupyter notebook

  • In your Jupyter environment, click on the 01-WaterFlow-Terse.ipynb document to open it. Note that it opens in a new browser tab and that the page opened has a mix of formatted text, Python code, and the results of the Python code.
  • Double click in the first text box, the one with Quick start: Impacts of Falls Lake on streamflow... in it. You see that converts to raw markdown format, which is how we can add rich text to our notebooks.
  • With the box still active hit the ►| button to "execute" the contents, which converts the raw markdown back to formatted text. Alternatively, you could click ctrl-enter to run the code.
  • The following box should now be active. (If not, just click on it.) Go ahead and run this code the same way as above (with the ►| button). This runs the code in the box and shows the result just below.
  • Restart the kernel by selecting Kernel>Restart & Clear Output. This resets the document, clearing all output, which is fine since we can just re-run our code!
  • Select Cells>Run All, which zips through all our code.
  • Save the document: File>Save and checkpoint (or click ctrl-s, or just click the save icon).
  • Close the document: File>Close and Halt. Note that if you just close the page displaying the document, it does not halt the kernel. It's best practice to halt the page when you are not editing it for a while.

Ok! We're ready to get started! If you've opened this document as a Jupyter notebook, you can save it and then "Close and Halt" it.