问题
Why do we have so many cells in jupyter notebook?
To execute a piece of code, normally we have one large space like in eclipse, net beans or any other IDE.I want to know what all we can do with the cells in jupyter notebook?
回答1:
The idea of Jupyter Notebook is that you can interleave code with explanatory text. This is why Jupyter offers two kinds of cells: code and markdown.
As an example, this is very useful for exploratory data analysis where you might want to write some prose in a markdown cell about where the dataset came from and what assumptions were made, then apply an algorithm in a code cell, plot the results in another code cell, and explain what it all means in another markdown cell.
Another advantage of cells is that you can execute them individually. Some algorithms might take a very long time (think machine learning) and don't have to be executed every time you make a change to another part of the notebook (e.g. plotting).
回答2:
The purpose it do be able to divide the code into several blocks. If you just run "Kernel -> Restart & Run All" it doesn't matter.
I prefer to use Notebooks to combine documentation and code, to explain the code. It is also useful to combine plots and regular output.
It is also useful when developing, you can divide the functionality into multiple chunks and don't need to run the code again.
回答3:
Cells let you save states. Imagine you need to read a large dataset and perform some machine learning on it. You can use one cell to read the dataset–only once–and you can continue your data explorations down in the notebook. It saves a lot of time.
来源:https://stackoverflow.com/questions/62402328/why-do-we-have-so-many-cells-in-jupyter-notebook-instead-of-one