-
Notifications
You must be signed in to change notification settings - Fork 4
Creating Notebooks
- Create a Blank Notebook
- Add a New Cell
- Run Code
- Download Notebooks
- Develop Locally
- Additional Resources
This section describes how to create a notebook on the JupyterHub infrastructure. Go to datahub.berkeley.edu. Click on the green "Start My Server" button.
Click on the "New" dropdown on the right side of the page. Select the option for "Python 3" under "Notebooks."
You will see a blank notebook to which you can now add text and code. The notebook consists of sections called cells. There are different types of cells that can be used. Code is part of the "code" cell type and text is part of the "markdown" cell types.
You can add a new cell using eiher the "+" button on the left side or the "Insert" button on the toolbar.
To set the type of this cell, click on "Cell" in the toolbar, then "Cell Type" and then either "Code" or "Markdown." Code can be directly typed in. Text must be added in markdown format. This is a good reference for markdown syntax.
Here is an example of what code and markdown cells with content will look like.
You will notice that there is no code output in the previous image. In addition, the text formatting is not properly displayed. To run code or see the formatted text, you must run the cell. An individual cell can be run by typing Shift-Enter from the cell. All cells can be run by clicking the play button in the toolbar (triangle with a line). You can also click on "Cell" in the toolbar for additional ways to run cells. Below is the output of running all cells.
You can run code by either typing Shift-Enter from the cell or clicking the play button in the toolbar (triangle with a line).
Code that has been run in one cell is accessible by another cell. If any changes are made to a cell, you must rerun all cells that you want affected by the change.
Click on “File” in the toolbar, then “Download as”, then select ‘Notebook (.ipynb).” This will download the notebook to your computer in the standard Jupyter notebook format. You can also download notebooks in alternate formats, seen below.
The above steps can also be done using a local installation of Jupyter Notebooks instead of the datahub.berkeley.edu infrastructure. If you choose to development assignments locally, we highly recommend that you upload and test the assignments on datahub.berkeley.edu as the local and cloud environments may be different.
- Markdown basics notebook - Double clicking on each cell allows you to see how a variety different content is formatted in Jupyter Notebooks.