<jupyter_start><jupyter_text>Quick intro to Jupyter Notebook*originally by <NAME>, modified by Baird*Jupyter notebooks are a noice tool for data analysis and code development.  This notebook explains the essentials to get you up and running.  InstallationWe will assume that you are using Anaconda.  To install Jupyter type:    conda install jupyter Notebook extensionsYou can add extended functionalities by installing notebook extensions:    conda install -c conda-forge jupyter_contrib_nbextensionsThis will add a tab to your dashboard, from where you can select the extension.  These include:* Collapsible heading extensions* Table of contents extensions* Cell runtime information,* ... and much more Notebook themesFor changing the look of the notebook, you want to run `pip install jupyterthemes`. This will allow you to select different themes. For more information visit: https://github.com/dunovank/jupyter-themes  Basic usageTo start a Jupyter notebook, type:    jupyter notebookin the command line. If you do this locally (e.g., on your laptop) this should automatically open up a browser window with the dashboard. We'll cover running a notebook remotely below.On the dashboard you can see all files in your current directory. (Note that you can click on any file and edit it.) Jupyter notebook files end in `.ipynb`. To create a new notebook, click on `New` and select a Python kernel. Now a new tab will appear with your empty notebook. CellsJupyter notebooks have cells such as this one, and there are different types. The two most useful ones are code cells and markdown cells.  This here is a markdown cell, which allows us to write formatted text using the "markdown" language. For a quick introduction, see here: https://github.com/adam-p/markdown-here/wiki/Markdown-CheatsheetNote that in markdown you can also type Latex:$x = \frac{a}{b}$To switch the cell type, either use the toolbar above or press `y` for code or `m` for markdown in command mode, which we will get to now. ModesTo navigate Jupyter notebooks there are two modes:1. Command mode, which you can enter by pressing `esc` (cells have a BLUE border)  * Lets you arrow up/down across cells, delete them, etc.2. Edit mode which you can enter by pressing `enter`/`return` (cells have a GREEN border)  * Lets you edit the text within a cell Keyboard shortcuts!If you get confused about all the keys just press `h` in command mode (may need to press `esc` to do this).  Of course, you can also use the mouse and the toolbar.  Executing a cellTo execute a cell, press `shift + enter`. This will run the code or render the text and jump to the next cell.  If you would like to insert a cell below, type `alt + enter`. Closing a notebook1. Save any changes, close the window2. Back at the dashboard, choose the "Running" tab, and shut down the notebook Closing an entire jupyter notebook sessionGo to the terminal shell and type `ctrl + c` TWICE ---Now let's start by actually writing some code.<jupyter_code># Import modules just as you would in a regular Python script
import numpy as np
import matplotlib.pyplot as plt
# Assign variables
a = 10
# The value of the last object in the cell will be displayed
b = 2
a
a + b<jupyter_output><empty_output><jupyter_text>*You do not have to work chronologically. You can always edit cells above.*  **But pay attention:  If they're out of order, you'll get an error if you close/open/re-run the notebook.**   **Get function docs**  Next, create a basic plot and also note a super-handy functionality of the notebook:  * When using a function and pressing `shift + tab` when the cursor is inside the function parenthesis, it will bring up the list of arguments.  Pressing it twice will bring up the doc string.Similarly, executing `?function_name` will bring up the doc string in a separate window. `??function_name` will bring up the source code.<jupyter_code>plt.hist(np.random.normal(size=1000))
plt.title('my histogram')
?plt.hist
??plt.hist<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0590738423028786, 'fraction_numerical': 0.002753441802252816, 'mean_word_length': 4.542302357836339, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '416151', 'license': 'MIT', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1041, 'n_words': 603, 'path': 'materials/week2/1-jupyter-notebook-intro.ipynb', 'repo_name': 'zmlabe/ESS-Python-Tutorial', 'size': '4001'}