Jupyter in Visual Studio Code – April 2021 Release

Claudia Regio

We are pleased to announce that the April 2021 release of the Jupyter Extension for Visual Studio Code is now available. If working with Python, we recommend installing the Python extension directly from the extension gallery in Visual Studio Code. If you already have the Python or Jupyter extensions installed, you can also get the latest update by restarting Visual Studio Code. You can learn more about Python support in Visual Studio Code in the documentation.  

This release of the Jupyter Extension includes an overhaul and new functionality of the Data Viewer, as well as some UI enhancements and multiselect support for Native Notebooks.  

If you’re interested, you can check the full list of improvements in our changelog. 

Data Viewer Enhancements 

Upgraded Data Viewer

We’ve added many improvements to our Data Viewer in the latest release. Firstly, we have added the ability to refresh the Data Viewer. If you’ve made some changes or transformations to your data, rather than having to close and reopen the Data Viewer to view the changes, you can now click the refresh button in the top left to grab the most up-to-date data. 

Secondly, the Data Viewer now supports viewing both PyTorch and TensorFlow Tensor data types! 

Finally, we’ve given the entire Data Viewer UI a visual update to make it more aesthetically pleasing. You can now find the filter box at the heading of each column. You can also continue to click on any column heading to sort its data ascending/descending. Lastly, you can now click into individual cells in the Data Viewer to copy out their contents. 

Data Slicing 

Data Slicing

The Data Viewer now has support for slicing data. This will allow you to view any 2D slice of your higher dimensional data. If you have 3-dimensional or greater data (numpy ndarrayPyTorch Tensor or TensorFlow EagerTensor types)you will now be able to view that multi-dimensional data in the Data Viewer and a new data slicing panel will open in the Data Viewer by default. In this panel, you will be able to either use an input box to programmatically specify your slice using Python slice syntax or use the interactive Axis and Index dropdowns to slice as well. Both will be in sync.  

VS Code Insiders – Native Notebooks

To try out Native Notebooks you need to download VS Code Insiders and make sure you have the Jupyter extension! Reminder that the Python extension comes with the Jupyter extension and when working with Python we recommend having both installed for the best Python experience.  

Multiple Cell Selection is Here!  

Jupyter Notebooks now have support for selecting multiple consecutive cells using the mouse (Shift + Click) or the keyboard shortcut (Shift + Arrow) when in cell selection mode.  

Multiselect with Shift

You can also select individual cells using the mouse (Ctrl + Click).  

Multiselect with Ctrl

Once the cells are selected, you can copy/cut/paste/duplicate and even move selected cells by dragging and dropping them to your preferred location.  

Moving Multiselected Cells

Quick Collapse 

You’ll no longer need to open the overflow menu in the cell toolbar to collapse cell inputs or outputs! Simply hover over to the left of each cell and double-click in order to collapse the elements of your cell.  To reveal collapsed content, just click the collapsed icon as shown below. 

Quick Collapse

Customizable Diffing Experience 

Users can now customize the type of information that is surfaced when diffing notebooks and have the option to hide metadata and output differences!  To customize your filters, simply open the overflow menu located in the top right of the rich diff text editor and select the sections on the notebook you would like included!  

Customizable Diffing Content

Other Changes and Enhancements 

We have also added small enhancements and fixed issues requested by users that should improve your experience working with Notebooks in Visual Studio Code. Some notable changes include: 

  • Variable view will stay as long as you have a notebook open (not necessarily active). (#4562) 
  • Ensure extensions depending on Jupyter do not fail to load if Jupyter extension fails to load. (#5145 
  • Fix data viewer display of non-numeric index columns in DataFrames. (#5253) 
  • When reopening a newly created Notebook with a Julia kernel, the cells should be detected as Julia. (#5148) 
  • Support switching kernels in Native Notebooks when connecting to Jupyter. (#1215) 
  • Refactor how Kernels are searched and selected. (#4995) 
  • Be able to provide string argument to jupyter.execSelectionInteractive for extensibility. (Thanks Andrew Craig) (#1689) 

Be sure to have the latest version of the Python and Jupyter Extensions for Visual Studio Code now to try out the above improvements. If you run into any problems or have suggestions, please file an issue on the Jupyter VS Code GitHub repository.