Datalore 2023.6 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 Control, +, Alt, +, Enter.

Add a code cell above the selected one

  1. Press Control, +, 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 Control, +, Shift, +, ArrowUp or Control, +, Shift, +, ArrowDown 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:

  • 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.

Link to cell

Copies the link to the cell to the clipboard.

Clear output

Clears the cell output.

Clear selected output

Clears the selected cell output.

Run cell

Runs the cell code.

Run all above

Runs the cell code.

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.

Optimize imports

  • Sorts imports statements.

  • Removes unused imports from the notebook or the selected code.

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: 23 November 2023