Use the main building element of your notebooks, code cells, to write and edit 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.
Write your code.
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 Run code.
Add a code cell below the selected one
Click the Add code cell button.
note
This button is only available after the cell that is currently last on the worksheet.
Click the + icon on the selected cell toolbar.
Press CtrlAltEnter.
Add a code cell above the selected one
Press CtrlShiftEnter.
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 CtrlShift0↑ or CtrlShift0↓ 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:
Select cell type: converts the code cell type into a Markdown or SQL cell (input converted accordingly).
Ask AI: opens the Ask AI tool that generates code suggestions for this code cell based on your prompts.
Insert code cell below: inserts a new code cell below the selected one.
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.
Copy 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.
note
The context menu that you call by right-clicking the area outside the editor field is not the same as the cell menu described above. The context menu provides a limited selection of cell-related actions and additionally allows to change the notebook view.
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.
To change how your cells are displayed, go to Main menu | View and try different options. For more information, see Customize the editor.
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.
note
Collapsing inputs and outputs does not affect content visibility for the other people with view or edit access. Each collaborator individually configures how they view the same notebook.
Datalore coding assistance
Datalore provides a wide range of tools and functionalities to help you generate, edit, and refine your code faster and more efficiently. To learn how to use the provided assistance, refer to this section.