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.
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.
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)
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