如何在 IPython Notebook 中隐藏一个特定的单元格(输入或输出)? [英] How to hide one specific cell (input or output) in IPython Notebook?

查看:20
本文介绍了如何在 IPython Notebook 中隐藏一个特定的单元格(输入或输出)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 IPython notebook 中选择性地隐藏一个特定的输入或输出单元?

我只能找到以下代码来显示/隐藏所有输入单元格.

除了整个单元格之外,您还可以仅过滤输入或仅过滤输出:

  • TagRemovePreprocessor.remove_input_tags
  • TagRemovePreprocessor.remove_single_output_tags
  • TagRemovePreprocessor.remove_all_outputs_tags

Is there a way to selectively hide one specific input or output cell in IPython notebook?

I could only find the below code to show / hide all input cells.

http://blog.nextgenetics.net/?e=102

But what if I only want to hide the first input cell of a notebook?

解决方案

This is now built into nbconvert (as of 5.3.0) using tags.

Here's an example removing a specific cell from the output. Using this notebook. The example has three cells: a markdown cell, a code cell that will be hidden, and a code cell that will not be hidden.

  1. Add the remove_cell tag to any cells you want to hide using the tag editor built into the notebook or JupyterLab (the specific name "remove_cell" doesn't matter)
  2. Convert with nbconvert

    jupyter nbconvert nbconvert-example.ipynb --TagRemovePreprocessor.remove_cell_tags='{"remove_cell"}'

Any cells with the tag remove_cell will be removed from the output.

In addition to entire cells, you can filter just inputs or just outputs:

  • TagRemovePreprocessor.remove_input_tags
  • TagRemovePreprocessor.remove_single_output_tags
  • TagRemovePreprocessor.remove_all_outputs_tags

这篇关于如何在 IPython Notebook 中隐藏一个特定的单元格(输入或输出)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆