I don't know the meaning of restart in the jupyter notebook

The mission link:https://app.dataquest.io/m/349/project%3A-learn-and-install-jupyter-notebook/6/hidden-state

What do I specifically restart?

And I don’t understand the meaning of the number in: in[number] on the left of a code cell.

Jupyter Notebook has cells where you can type in your code and run it. But the beauty of Jupyter is that you can actually use it like a coding notebook. In one code cell you can write code and add a markdown cell below it and explain the code. Later you will be able to add plots and many other things.

So each of this cell can be run independently for any number of times. Each time it gets executed the line number gets updated by 1. If you execute each cell only once, all the cell numbers will be in sequential order and look like 1,2, 3, 4 etc

But if you decide to go back and run cell number 2 when you have are at lets say cell 5, after running cell number 2 will be updated as cell number 7. So it basically shows the order in which you have run it and re-run it.

When you click restart from kernel tab, the whole notebook will be reset. By saying that, it means all the variables stored will be lost. Usually we need to do this if Notebook gets hang or something like that happens.

But if you click Restart and Clear Output it is used to restart the Kernel of the Notebook and reset all the cells that were run previously.

Next option is Restart and Run all and this is used to restart the Kernel of the Notebook, and reset all the cells that were run previously, and finally re-run through all the cells of the Notebook.

1 Like

@Maho:

Restart is meant to shut the kernel down and spin out a new instance and there may several reasons why you would want to do so, including making jupyter extensions, although I do not usually use it. More details can be found in this article. Note that it clears all local variables (i.e. values saved to variables, files generated etc.)

Most Jupyter Notebook extensions can be installed using Python’s pip tool. If you find an extension that can’t be installed with pip, then you will likely have to use the following command:
$ jupyter nbextension install EXTENSION_NAME
This only installs the extension but does not make it active. You will need to enable an extension after installing it by running the following:
$ jupyter nbextension enable EXTENSION_NAME

You may need to restart your Jupyter Notebook kernel to see the extension.
There is a nice meta extension called Jupyter NbExtensions Configurator that is worth getting for managing other extensions. It allows you to enable and disable your extensions from within the Jupyter Notebook’s user interface and also shows all the currently installed extensions.

The number shows the sequence in which you run the cells. Numbering starts at 1. This can be useful if you need to run a certain portion of code multiple times (e.g. to load dependencies) before running the main code.

I usually use restart and run all if I have changed some code to flush the memory and run the cells automatically, which eliminates the need to run all of the cells manually with Shift + Enter.

1 Like

But when I press restart I don’t see anything changed except the numbers on the left of cells.

But when I press restart I don’t see anything changed except the numbers on the left of cells

Yes, it the kernel ( for easier understanding lets call it the notebook) gets restarted to its initial state where numbers starts from 1. Most probably you don’t have to use restart at the moment as there are no issues with your kernal. Most of the time, you will use “restart and rerun all the cells” when you want to troubleshoot some errors.

1 Like

I can understand from you that restart only means to reset numbers of cells, am I right?
But what about clear output?What does it mean ( I’ve tried it and noticed that only numbers change )?

Restart and Run all cell will reset the numbers
Restart and clear out will clear the numbers
Restart will clear the assigned value and their values will be lost.

When you restart, for example dq='Dataquest' in 1st cell will not be assigned.
You can try by restarting and run the cell 2. You will get an error NameError: name 'welcome' is not defined because the variables defined in the first cell has lost their values during reset.