Skip to Content

Undo cell deletion in Jupyter Notebook

You have a number of unwanted cells in your notebook and you are on a deletion spree. Unfortunately, you delete a cell that you didn’t intend to delete and now don’t know what to do. Don’t worry, there’s a way to recover back your deleted cell. In this tutorial, we’ll look at how to undo cell deletion in a Jupyter Notebook.

For a quick refresher on the Jupyter Notebook interface, refer to our introductory guide.

You can recover a deleted cell in a jupyter notebook with the Edit menu. Go to Edit -> Undo Delete Cells to undo the delete operation performed on the cells and recover back your deleted cell.

Edit menu in jupyter notebook showing Undo Delete Cells option

Note that the Undo Delete Cells option will only be accessible if there are cells that have been deleted.

You can use a keyboard shortcut to recover your deleted cells in a jupyter notebook. For this, first, switch to command mode using the Esc key and then press z to recover your deleted cell.

Note that, both the methods, will undo the cell deletion inside your jupyter notebook one at a time if the cells were also deleted one at a time.

We hope that this tutorial provided some value to you and gave you the information that you needed. Jupyter Notebooks are quite useful and knowing your way around them can certainly speed up your future tasks. You can create and share notebooks containing text, live code, visualizations, etc. It is this versatility that has made Jupyter Notebooks one of the most popular data science tools. Not only are these notebooks preferred by data scientists but they’re also quite popular among researchers across the globe.


Subscribe to our newsletter for more informative guides and tutorials.
We do not spam and you can opt out any time.


Author

  • Piyush Raj

    Piyush is a data professional passionate about using data to understand things better and make informed decisions. In the past, he's worked as a Data Scientist for ZS and holds an engineering degree from IIT Roorkee. His hobbies include watching cricket, reading, and working on side projects.