collapse cell in jupyter notebook
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Orient Looping
--
Chapters
00:00 Collapse Cell In Jupyter Notebook
00:26 Answer 1 Score 36
00:46 Accepted Answer Score 159
01:46 Answer 3 Score 26
02:32 Answer 4 Score 97
02:42 Thank you
--
Full question
https://stackoverflow.com/questions/3315...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #ipython #ipythonnotebook #jupyter
#avk47
ACCEPTED ANSWER
Score 159
UPDATE:
The newer jupyter-lab is a more modern and feature-rich interface which supports cell folding by default. See @intsco's answer below
UPDATE 2
Since jupyter-lab now also supports extensions, you can extend the built-in cell-folding functionality with the Collapsible_Headings extension.
Original answer:
The jupyter contrib nbextensions Python package contains a code-folding extension that can be enabled within the notebook. Follow the link (Github) for documentation.
To install using command line:
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
To make life easier in managing them, I'd also recommend the jupyter nbextensions configurator package. This provides an extra tab in your Notebook interface from where you can easily (de)activate all installed extensions.
Installation:
pip install jupyter_nbextensions_configurator
jupyter nbextensions_configurator enable --user
ANSWER 2
Score 97
JupyterLab supports cell collapsing. Clicking on the blue cell bar on the left will fold the cell.

ANSWER 3
Score 36
You can create a cell and put the following code in it:
%%html
<style>
div.input {
display:none;
}
</style>
Running this cell will hide all input cells. To show them back, you can use the menu to clear all outputs.
Otherwise you can try notebook extensions like below:
https://github.com/ipython-contrib/IPython-notebook-extensions/wiki/Home_3x
ANSWER 4
Score 26
I had a similar issue and the "nbextensions" pointed out by @Energya worked very well and effortlessly. The install instructions are straight forward (I tried with anaconda on Windows) for the notebook extensions and for their configurator.
That said, I would like to add that the following extensions should be of interest.


