折叠 jupyter 笔记本中的单元格 [英] collapse cell in jupyter notebook
问题描述
我正在使用 ipython Jupyter 笔记本.假设我定义了一个在屏幕上占据大量空间的函数.有没有办法折叠单元格?
I am using ipython Jupyter notebook. Let's say I defined a function that occupies a lot of space on my screen. Is there a way to collapse the cell?
我希望函数保持执行和可调用状态,但我想隐藏/折叠单元格以便更好地可视化笔记本.我该怎么做?
I want the function to remain executed and callable, yet I want to hide / collapse the cell in order to better visualize the notebook. How can I do this?
推荐答案
更新:
较新的 jupyter-lab
是一个更现代且功能丰富的界面,默认情况下支持单元格折叠.请参阅下面@intsco 的回答
The newer jupyter-lab
is a more modern and feature-rich interface which supports cell folding by default. See @intsco's answer below
更新 2
由于 jupyter-lab
现在也支持扩展,您可以使用 Collapsible_Headings
扩展.
Since jupyter-lab
now also supports extensions, you can extend the built-in cell-folding functionality with the Collapsible_Headings
extension.
原答案:
jupyter contrib nbextensions
Python 包包含一个代码-可以在笔记本内启用的折叠扩展.按照链接 (Github) 获取文档.
The jupyter contrib nbextensions
Python package contains a code-folding extension that can be enabled within the notebook. Follow the link (Github) for documentation.
使用命令行安装:
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
为了更轻松地管理它们,我还推荐 jupyter nbextensions configurator
包.这在您的 Notebook 界面中提供了一个额外的选项卡,您可以从中轻松(取消)激活所有已安装的扩展.
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.
安装:
pip install jupyter_nbextensions_configurator
jupyter nbextensions_configurator enable --user
这篇关于折叠 jupyter 笔记本中的单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!