Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to freeze a cell alone with its outputs on a jupyter notebook

When using Jupyter notebook, outputs (include error messages) from executing a cell can be useful and so I'd like to freeze the cell alone with its outputs, or in another word, to inactivate the cell in order to keep the output.

Is this doable?

like image 363
H.C.Chen Avatar asked Jan 08 '18 07:01

H.C.Chen


1 Answers

This freezes the cell, but not the output:

  1. Open the notebook in an editor.

  2. Look for the cell you want to lock.

  3. Add the following lines to the metadata of the cell:

    "metadata": {
        "trusted": true,
        "editable": false,
        "deletable": false
    }
    
  4. Save and reload the notebook in Jupyter and... Tadah!, your cell can't be modified or deleted.

Unfortunately, the outputs can still be cleared by intentionally selecting that option in the menu bar (Edit > Clear Ouputs). Of course that can only happen if you DO WANT to clear the outputs and not just update them by running the cell.

Source

like image 78
Mr. Duhart Avatar answered Nov 13 '22 23:11

Mr. Duhart