Datalore Help

Code cells

Code cells contain executable code. The default language that you use in code cells is Python. However, you can choose Kotlin when creating a notebook.

First code cell

By default, the empty code cell is where you start coding in your new notebook. Your cursor is already placed inside this cell.

  1. Write your code.

  2. Click the Run icon in the upper-left corner of the cell to have the code executed. The result of the computation (output) will be displayed in the same cell right under the input.

You can use more run options. For more information, see Code running options.

Add a code cell below the selected one

  • Click the Add code cell button.

  • Click the + icon on the selected cell toolbar.

  • Press Ctrl + Alt + Enter.

Add a code cell above the selected one

  1. Press Ctrl + Shift + Enter.

  2. Right-click anywhere in the editor field and select Insert code cell above from the menu.

Move cells

Now that you have more than one cell in your notebook, you can reorder them:

  • Press Ctrl + Shift + ↑ or Ctrl + Shift + ↓ to move the selected cell one cell up or one cell down.

  • Right-click the cell and try the same actions from the cell menu.

Code cell toolbar

Located in the upper-right corner of the cell frame, the toolbar contains the following icons:

  • Change cell visibility: allows to control which cell parts other users can see.

  • Insert code cell below: inserts a new code cell below the selected one.

  • Select cell language: allows to change the code cell type and converts the input into the selected language.

  • Delete cell: deletes the cell from the notebook.

  • More actions: provides more options to insert, run, and move cells, or extract code to file.

Additionally, code cells have the Run icon. Located in the upper-left corner, it executes the cell input and displays the output.

Code cell menu

The code cell menu is a popup menu opened by right-clicking anywhere in the code cell. This element contains an expanded selection of actions to manage the cell and its input.

Action

Details

Insert code cell above/below

Inserts a new code cell below or above the selected one.

Insert cell above/below

Inserts a cell of a selected type below or above the selected one.

Delete cell

Deletes the selected cell.

Change cell type

Changes the type of the selected cell and converts the input.

Split cell at cursor

Splits the cell in two where the cursor is positioned.

Clear output

Clears the selected cell output.

Copy/Cut/Paste

Copies, cuts, and pastes the selected or highlighted input.

Go to declaration

Used to navigate to the declaration of the selected/highlighted variable.

Rename

Used to rename the selected/highlighted variable.

Reformat code

Reformats the input of the selected code cell.

Move cell up/down

Moves the selected cell one cell up or one cell down.

Code cell output and view

You can have different kinds of code cell output, including text, tables, graphics, and so on. By default, the layout of a code cell displays both its code and output placed vertically.

Python code cell with its output

To change how your cells are displayed, go to Main menu | View and try different options. For more information, see Editor view.

Collapse inputs and outputs

When working with big notebooks, you may want to collapse some or all of its inputs or outputs. You have the following options:

  • Collapse all inputs or outputs: go to Main menu | View and select the required action.

  • Collapse the input or output of a specific cell: click one of the two minus controls on the left side of the cell. To expand it, click the plus control.

    Collapsing cell input
Last modified: 15 November 2021