DataSpell 2022.3 Help

Edit Jupyter notebook files

Set up your workspace and environment

  1. Open your workspace.

  2. Install the jupyter package for the selected interpreter.

  3. When all the indexing processes are finished, you are ready to start working with the notebook files.

To open an existing .ipynb file, follow the same steps as for the files of the other types. If needed, you can create a notebook file.

Create a notebook file

  1. Do one of the following:

    • Right-click the target directory in the Workspace tool window, and select New from the context menu.

    • Press Alt+Insert

  2. Select Jupyter Notebook.

    Adding a new file
  3. In the dialog that opens, type a filename.

A notebook document has the *.ipynb extension and is marked with the corresponding icon.

Add cells

  • A newly created notebook contains one code cell. You can change its type with the cell type selector in the notebook toolbar:

    Select a cell type
  • Add more code or Markdown cells to your notebook. You can add a code cell after the very last cell, add a code cell or Markdown cell right after the selected cell, and insert a new cell after executing the selected cell. You can find these actions in the Cell menu.

    Adding a notebook cell

  • To edit a code cell, just click it.

  • To edit a Markdown cell, double-click it and start typing. To preview the output, press Shift + Enter.

You can apply various editing actions to one cell or to the entire notebook. Press the Ctrl+A once to select a cell at caret, and press Ctrl+A twice to select all cells in the notebook.

When editing notebook files, mind that DataSpell updates the source code and preview of the notebook if it has been changed externally.

Use code assistance

You can edit code cells with the help of Python code insights, such as syntax highlighting, code completion, and so on.

  • DataSpell enables Code completion for the names of classes, functions, and variables. Start typing the name of the code construct, and the suggestion list appears.

    Function completion
    Class variable completion
    Path completion
    Package completion
    DataFrame column name completion
  • Intention actions and quick fixes. You can add the missing imports on-the-fly by using the intention actions.

    Quick-fix for the missing import

    Note that you can add an import statement to the current cell or to the first cell of the notebook.

Cell selection

  • To select several cells in the command mode, press Shift and Up/Down keys.

Copy and paste cells

  • To copy a cell in a command mode, press Ctrl+C or click Copy cell on the notebook toolbar.

  • To paste the copied cell below, press Ctrl+V or click Paste Below Cell. To paste it above the current cell, press Shift with Ctrl+V

Split and merge cells

  • To merge a current cell with the cell below, right-click the cell and select Merge Cell Below command from the context menu.

    Similarly, you can merge a cell above the selected cell with the corresponding command.

  • To split a cell into two cells, set the cursor on the line to break at, then right-click, and select the Split Cell from the context menu.

Delete cells

  • To delete a selected cell, do one of the following:

You can preview the outline of the Markdown headings in the Structure tool window. To open it, select Window | Tool Windows | Structure from the main menu.

Notebook structure
  • Click Navigate with Single click to navigate from the selected heading in the editor to the corresponding item in the Structure tool window.

  • Similarly, click Always select opened element to navigate from the selected item in the notebook structure to the corresponding Markdown cell.

Compare notebooks

  1. To compare any two notebooks, select one in the Workspace tool window, right-click it, and select Compare With from the context menu (Ctrl+D).

  2. In the file system, select a notebook you want to compare to.

  3. DataSpell shows two notebooks and the comparison results in the diff viewer:

    compare two notebooks
  4. You can modify each of the compared notebooks by using the buttons: apply diff change and apply diff change. You can also edit the notebooks directly in the diff viewer. Once the change is applied, DataSpell saves it.

Last modified: 11 January 2023