<jupyter_start><jupyter_text>Jupyter notebooks Markdown cellsThis is a Markdown cell. Double-click on it and you can see it in its raw format and begin editing it. Once you're done editing, you can render it again by pressing `CTRL+Enter`. You have some limited formatting functionality with Markdown, such as making words **bold** and *italic*, or adding [hyperlinks](https://www.washington.edu/).You can also add images:![some label](https://bioe.uw.edu/wp-content/uploads/2014/01/block-w-header-blog.png)If the image you're adding is local, then just point to it's path relative to the notebook, such as `./images/my_image.jpg`. Absolute paths work too, but relative paths are better. listsYou can also create nested bulleted lists:- fruits  - persimmon  - guanabana- veggies  - onions  - garlicor numbered lists1. study1. drink coffee1. repeatNotice how you can number every item with 1. When it renders it will automatically increment.  code cellsThere's a lot more you can do with Markdown, but we have the basics covered. Now let's look at code cells. Run the cell below using `CTRL+Enter` and see how the Python code runs and any output it creates shows up right under it. So there is a Python session serving this current Notebook.<jupyter_code>str = "this is a Python string"
print(str)<jupyter_output>this is a Python string<jupyter_text>This is why it's important to keep in mind that1. When you're done with a notebook, don't just close the browser tab. Instead, go to **File > Close and Halt** so that in addition to closing the notebook it terminates the underlying Python session. Otherwise you'll have many Python sessions open for no reason (you can later kill them from the task bar too).1. Code cells have some visual clues that can help you. Next to a new code cell you see `In [ ]`, showing the cell hasn't run yet. Once you run it you get `In [n]` where `n` starts at 1 for the first cell you run and keep incrementing by 1 every time you run a code cell.1. **The order in which you run code cells is important**, and accidentally re-running a code cell can mess things up in some cases. Here's an example:<jupyter_code>a = 1
a += 1
print(a)<jupyter_output>5<jupyter_text>What happens if you run the above cell a few times? Create a new code cell below (go to **Insert > Insert Cell Below**) and print the value of `a` to check it. So how could we have avoided that problem, so that `a` always evaluates to 2? The answer, merge the two code cells above into one (select the cell with `a += 1` and go to **Edit > Merge Cell Above**).How can we avoid such mistakes?- Try to avoid running cells in random orders. If you want to test your code up to a certain point, then go to **Cell > Run All Above**.- Avoid having cells whose states depend on other cells, like we saw with the above example.- Avoid having too many variables in the same notebook with the same names.- Before submitting your assignments, make sure you re-run the notebook from scratch to make sure everything worked. Just go to **Kernel > Restart and Run All**.  cell shortcutsThere are many useful keyboard shortcuts that can make it easier to work with notebooks. To see all of them just click on the little keyboard icon in the menu bar. Here are some of the most important ones:- `CTRL+Enter`: Run current cell, but stay in with current cell after running.- `SHIFT+Enter`: Run current cell and jump to the next cell. You can use this to run through the whole notebook one cell at a time.- If you select a cell and press `a` and `b`, it will create a new cell above and below the current cell, respectively. This only works if you have selected the cell but are not in edit mode (if you see your cursor flashing in the current cell, that means you're in edit mode). To leave edit mode, either press `Escape` or click on somewhere in the margin to the left or right side of the cell.- `CTRL+SHIFT+-`: When you're in edit mode inside a cell, this command will split the cell in two based on where you have the cursor.- `d+d`: Pressing `d` twice will delete the cell you've selected.  cell magicsCell [magics](https://ipython.readthedocs.io/en/stable/interactive/magics.html) are little commands **at the top of a cell, starting with % or %%**. They serve as shortcuts for doing some common tasks. They can save you a lot of time! Here's some common ones: - `%magic` lists all Jupyter magics.<jupyter_code>%magic<jupyter_output><empty_output><jupyter_text>- If you want to create a raw text file (Python script in this example, but works with any text file), you can use `%%writefile` followed by the name of the file, followed by its content starting in line 2.<jupyter_code>%%writefile script.py
a = 'hello world'
print(a)<jupyter_output>Writing script.py<jupyter_text>- If you want to run a Python script you can use `%run`. This will run it using a **new** Python session. You can also run it with the Python session hosted by the notebook if you use the `-i` flag.<jupyter_code>%run script.py<jupyter_output>hello world<jupyter_text>- `%time` can give you the run-time of a cell.  Python shortcutsOne last notable that will help you in the course is the use of the `Tab` key to auto-complete something. This doesn't always work, but when it does it's neat. Say you just imported `pandas` and want to read a CSV file.<jupyter_code>import pandas as pd<jupyter_output><empty_output><jupyter_text>You know it's probably `pd.read` but you don't remember the exact function name. Type `pd.re` and then press `Tab` and you should see a drop-down list of available functions.<jupyter_code>pd.read_csv()<jupyter_output><empty_output><jupyter_text>Once you found the right function, now you might be wondering what the name of the arguments are. Then type `pd.read_csv()` and with **your cursor in between the two parentheses** now press `SHIFT+Tab+Tab`. A little documentation page should pop.<jupyter_code>pd.read_csv()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0712721145745577, 'fraction_numerical': 0.0035383319292333613, 'mean_word_length': 4.501390176088972, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 34, 'https://': 3, 'lorem ipsum': 0, 'www.': 1, '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': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '53615', 'license': 'MIT', 'n_tokens_mistral': 1646, 'n_tokens_neox': 1577, 'n_words': 926, 'path': 'lesson_1.ipynb', 'repo_name': 'sethmott/datasci400', 'size': '5935'}