Deleting a Cell in Jupyter Notebook


Jupyter Notebook is an interactive computational environment that allows users to create and share documents that contain live code, equations, visualizations, and narrative text. One of the most common tasks when working with Jupyter Notebook is deleting a cell. In this comprehensive guide, we will cover the different ways to delete a cell in Jupyter Notebook.

Why Would You Need to Delete a Cell?

Deleting a cell in Jupyter Notebook is a common task that every data analyst or scientist should know how to do. There are several reasons why you would need to delete a cell:

1. You made a mistake: It’s not uncommon to make mistakes while coding, and sometimes it’s faster to delete a cell and start over than to try to fix the mistake.

2. You no longer need the code: As you work on your notebook, you may find that some cells are no longer relevant to your analysis. In this case, deleting these cells can help clean up your notebook and make it easier to navigate.

3. You want to reorder your code: In some cases, you may want to change the order of your code in your notebook. Deleting a cell can help you achieve this by allowing you to move cells up or down.

Whatever the reason may be, deleting a cell in Jupyter Notebook is a simple process that can save you time and help keep your notebook organized.

Methods for Deleting a Cell

Deleting a cell in Jupyter Notebook can be done using different methods. In this section, we will discuss three methods for deleting a cell: using the Edit Menu, using Keyboard Shortcuts, and using the Right-Click Menu.

Using the Edit Menu

To delete a cell using the Edit Menu, follow these steps:

1. Select the cell you want to delete by clicking on it.
2. Click on the “Edit” menu located at the top of the screen.
3. Click on “Delete Cells” in the dropdown menu that appears.

Using Keyboard Shortcuts

Using keyboard shortcuts is a faster way to delete a cell. To do this, follow these steps:

1. Select the cell you want to delete by clicking on it.
2. Press “D” twice on your keyboard.

Note that when you press “D” once, nothing happens. You need to press it twice to confirm that you really want to delete the selected cell.

Using the Right-Click Menu

Another way to delete a cell is by using the Right-Click Menu. Here are the steps:

1. Right-click on the cell you want to delete.
2. Click on “Delete Cells” in the dropdown menu that appears.

It’s important to note that when you delete a cell in Jupyter Notebook, it cannot be undone. Therefore, make sure you really want to delete a cell before proceeding with any of these methods.

Undoing a Deleted Cell

In Jupyter Notebook, deleting a cell is a common operation that can be done with just a few clicks. However, what if you accidentally delete a cell and want to undo the operation? Fortunately, Jupyter Notebook has a robust undo feature that allows you to restore deleted cells.

To undo a deleted cell in Jupyter Notebook, you can use the Edit menu or keyboard shortcut. The Edit menu can be accessed from the top menu bar, while the keyboard shortcut is Ctrl + Z on Windows and Linux or Command + Z on Mac. This will undo your last action, whether it was deleting a cell or any other operation.

If you have deleted multiple cells and want to undo all of them at once, simply keep pressing Ctrl + Z or Command + Z until all the cells are restored. Alternatively, you can go to the Edit menu and select “Undo Delete Cells” to restore all deleted cells in one go.

It’s important to note that Jupyter Notebook only stores the last 30 actions by default, so if you have performed more than 30 actions since deleting the cell, you may not be able to undo the deletion. In this case, you may need to manually recreate the deleted cell.

In conclusion, undoing a deleted cell in Jupyter Notebook is easy and straightforward. Whether you use the Edit menu or keyboard shortcut, Jupyter Notebook’s undo feature allows you to quickly restore any mistakenly deleted cells.


In this comprehensive guide, we have learned how to delete a cell in Jupyter Notebook using various methods. We explored the different ways to delete a cell, including using the Edit menu, keyboard shortcuts, and context menu.

We also learned about undoing and redoing cell deletion, as well as permanently deleting cells from the notebook. Additionally, we covered some tips and tricks for working with cells in Jupyter Notebook.

By mastering these techniques, you can easily manage your Jupyter Notebook cells and streamline your workflow. Whether you are a beginner or an advanced user, these tips will help you become more efficient when working with Jupyter Notebook.

Overall, deleting a cell in Jupyter Notebook is a simple process that can be done in various ways. By understanding the different methods available to you, you can choose the one that best suits your needs and preferences.
Interested in learning more? Check out our Introduction to Python course!

How to Become a Data Scientist PDF

Your FREE Guide to Become a Data Scientist

Discover the path to becoming a data scientist with our comprehensive FREE guide! Unlock your potential in this in-demand field and access valuable resources to kickstart your journey.

Don’t wait, download now and transform your career!

Pierian Training
Pierian Training
Pierian Training is a leading provider of high-quality technology training, with a focus on data science and cloud computing. Pierian Training offers live instructor-led training, self-paced online video courses, and private group and cohort training programs to support enterprises looking to upskill their employees.

You May Also Like

Data Science, Tutorials

Guide to NLTK – Natural Language Toolkit for Python

Introduction Natural Language Processing (NLP) lies at the heart of countless applications we use every day, from voice assistants to spam filters and machine translation. It allows machines to understand, interpret, and generate human language, bridging the gap between humans and computers. Within the vast landscape of NLP tools and techniques, the Natural Language Toolkit […]

Machine Learning, Tutorials

GridSearchCV with Scikit-Learn and Python

Introduction In the world of machine learning, finding the optimal set of hyperparameters for a model can significantly impact its performance and accuracy. However, searching through all possible combinations manually can be an incredibly time-consuming and error-prone process. This is where GridSearchCV, a powerful tool provided by Scikit-Learn library in Python, comes to the rescue. […]

Python Basics, Tutorials

Plotting Time Series in Python: A Complete Guide

Introduction Time series data is a type of data that is collected over time at regular intervals. It can be used to analyze trends, patterns, and behaviors over time. In order to effectively analyze time series data, it is important to visualize it in a way that is easy to understand. This is where plotting […]