Change cell metadata

I want to somehow save my values IPython.html.widgetsin my ipython laptop.

Is there a way to change the metadata of the current cell from the code inside the cell itself?

+4
source share
2 answers

If I understand what you're looking for: from Cell Toolbar(at the top right of the ipython laptop toolbar) select Edit Metadatafrom the drop-down list.

+3
source

I don’t know how to do this from inside the laptop, but I found a way to do this using preprocessor and nbconvert.

, nbconvert.preprocessors.ExecutePreprocessor. preprocess ( preprocess_cell) .

- :

class MyExecutePreprocessor(ExecutePreprocessor):
    def preprocess_cell(self, cell, resources, index):
        # Execute the cell normally
        cell, resources = super().preprocess_cell(cell, resources, index)
        # Add your magic here
        cell.metadata['widgets'] = {'stuff':'that is cool'}
        return cell, resources

nbconvert.

+2

Source: https://habr.com/ru/post/1542362/


All Articles