Using these notebooks

This workbench is created using Jupyter notebooks. Jupyter lets you combine text, images, and live code within a single web page. So not only can you read about collections data, you can download it, analyse it, and visualise it – all within your browser!

Running code cells

Most of the notebooks here include snippets of real code contained within cells. To run these snippets, just click on the cell and hit Shift+Enter. Try it with the cell below!

In [ ]:
# CLICK ON ME AND THEN HIT SHIFT+ENTER!

# This makes the datetime module available to use
import datetime

# This creates a variable called 'date_now' and uses the datetime.date.today() function to set it to today's date.
date_now = datetime.date.today()

# This displays a nicely-formatted string containing the date
print("Congratulations! On {} you ran the code in this cell.".format(date_now))

**Help! Nothing happens when I click!**

If nothing happens when you click on a cell or hit **Shift+Enter** it's probably because you're viewing a static version of the notebook. See Introduction for setting up a live version.

You can also run the code in a cell by clicking on the 'Run' icon in the toolbar, or by hitting Control+Enter. You'll notice that Shift+Enter runs the code and moves you on to the next cell, while Control+Enter leaves you where you are.

Any variables or functions defined within a cell are made available to the rest of the notebook when you run it. So we can use the date_now variable defined above in any cell.

In [ ]:
# Run me to see how we can access the 'date_now' variable

# This gets the year from the date stored in the date_now variable.
date_now.year

**Help! I get a weird 'Name Error' saying that 'date_now' is not defined.**

If you get a message about a NameError, make sure that you've run the first code cell (where we create the 'date_now' variable, before this one.

You might have noticed that after a cell has been run a number appears in the square brackets – In [ ]:. This helps you keep track of which cells have been executed. While the code in a cell is running you'll see an asterix – In [*]:. This changes to a number once the code has completed.

Some of the notebooks in this workbench include many code cells defining functions and setting up variables for later use. Just run the cells in the order they appear to make sure that everything works as expected. If you get an error, check back to make sure all the relevant cells have been executed.

In some cases, cells will start processes that take a bit of time to complete. For example, harvesting series data from RecordSearch can take lots of time depending on how big the series is. You won't be able to run any more cells until the current one has finished. Just wait for the asterix to turn into a number and you'll be right to move on.

Adding and editing cells

In many places throughout this workbench, you'll be asked to edit or add to the code. That's how you learn! Just click on any code cell to start editing (double click on a Markdown cell). Try this!

In [ ]:
# Edit this cell to add your name between the quotes, and then run it
your_name = 'Tim'
print('Hi {}! Welcome to the OzGLAM workbench. 👋'.format(your_name))

To add a new cell, you just click the + icon in the toolbar at the top of the page. By default, the new cell will be expecting code, but you can change this by selecting 'Markdown' in the dropdown list of types in the toolbar.

In [ ]: