# Notebooks (/docs/projects/notebooks.md)



A notebook is a sequence of **code**, **markdown** and **SQL** cells.

* **Run** a cell from its run button. Running a cell with no compute attached opens the attach dialog.
* **Change the type** of a cell with the cell type switcher.
* **Format markdown** with the toolbar that appears while you edit a markdown cell.
* **Per-cell menu** — more actions on each cell, and **Ask AI** to generate or edit its code.

SQL cells come in two kinds and are described in [SQL cells](/docs/sql-and-data/sql-cells.md).

## Adding a cell [#adding-a-cell]

* **Between cells:** hover the gap between two cells, or above the first one. The gap opens to show
  **Python**, **SQL** and **Markdown**; pick one and the new cell appears right there.
* **At the end:** the row under the last cell is always visible, with the same three choices.
* **From the keyboard:** press `Esc` to leave the editor, then `A` to add a cell above or `B` to add one
  below. You stay in command mode, so `A A A` adds three cells. A cell added after a SQL cell is a SQL cell
  on the same connection; otherwise it is a Python cell.
* **`Ctrl+Shift+Enter`** (`Cmd+Shift+Enter` on a Mac) adds a cell at the end and puts the cursor in it,
  from anywhere in the notebook.

In command mode, `S` turns the selected cell into a SQL cell and `Y` turns a SQL cell back into Python.

## Copying output [#copying-output]

Hover any output and use the **copy** button in its top-right corner. What you get depends on the output:

| Output                | Copies as                           | Pastes as                                        |
| --------------------- | ----------------------------------- | ------------------------------------------------ |
| Printed text, results | Text                                | Text                                             |
| An error              | The traceback, without colour codes | Text                                             |
| A table (a DataFrame) | The table, plus tab-separated text  | Cells in Google Sheets or Excel, a table in Docs |
| A chart               | A PNG image                         | A picture in Slack, Docs or an email             |

Charts also have a **download** button that saves them as `chart.png`. A short message at the bottom of the
screen confirms each copy.

To copy all of a cell's output at once, open the cell's **⋯** menu and choose **Copy output**. This copies
the text of every output (tables in their text form, charts left out).

<Shot id="run-cell" alt="A notebook after Run all: a table of results and a bar chart under their cells" />

A notebook is a normal `.ipynb` file. It opens in JupyterLab unchanged, and ByteRun-specific cells
degrade to ordinary code cells.
