Skip to content

Instantly share code, notes, and snippets.

@swayson
Created May 26, 2015 09:23
Show Gist options
  • Save swayson/2de9f75f6d9bc744d256 to your computer and use it in GitHub Desktop.
Save swayson/2de9f75f6d9bc744d256 to your computer and use it in GitHub Desktop.
test
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"IPython Notebook Basics"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Project directory"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* IPython Notebooks are just files (`.ipynb`) on your file system\n",
"* The Notebook server is aware of Notebooks in a single directory, which we call the **Notebook directory**\n",
"* If you cd to a Notebook directory and type:\n",
"\n",
" ipython notebook\n",
"\n",
" you will see the Notebooks in that directory in the dashboard"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Notebook files"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Notebook files:\n",
"\n",
"* Are just that - files (`.ipynb`) on your file system\n",
"* Contain JSON data"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from IPython.nbformat import current\n",
"with open('00 - Notebook Basics.ipynb') as f:\n",
" nb = current.read(f, 'json')"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"nb.worksheets[0].cells[0:5]"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* Embed code, Markdown text, LaTeX equations, images\n",
"* Are version control friendly: post your Notebooks on GitHub\n",
"* Can be viewed online by anyone at http://nbviewer.ipython.org"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"IPython Notebooks can also be exported to `.py` files (see \"File:Download As\" menu item). You can tell the Notebook server to always save these `.py` files alongside the `.ipynb` files by starting the Notebook as:\n",
"\n",
" ipython notebook --script\n",
"\n",
"You can import Notebooks from the main Dashboard or simply by copying a Notebook into the Notebook directory."
]
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Exercise"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Find a Notebook on http://nbviewer.ipython.org and Download it. Then import it into your running Notebook server using the Dashboard."
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Overview of the UI"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* Dashboard\n",
"* Notebook area and cells\n",
"* Menu\n",
"* Toolbar"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Cell types"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* Code\n",
"* Markdown\n",
"* Raw text\n",
"* Heading"
]
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Exercise"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create a new Notebook that has at least one of each cell type. Practice the following cell operations:\n",
"\n",
"* Moving up/down\n",
"* Cut/Copy/Paste\n",
"* Merge/Split"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Keyboard shortcuts"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* `Shift-Enter` to run a cell\n",
"* `Ctrl-Enter` to run a cell in place\n",
"* All other keyboard shortcuts have the form: `Ctrl-m ?`\n",
"* Show all keyboard shortcuts using `Ctrl-m h`"
]
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Exercise"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Go back to that last Notebook and repeat some of those cell operations using keyboard shortcuts:\n",
"\n",
"* Inserting cells above/below\n",
"* Delete cell\n",
"* Move cell up/down\n",
"* Cut/copy/paste cell\n",
"* Changing cell types"
]
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment