1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Multiple versions of single Jupyter Notebook for different audiences (e.g....

Discussão em 'Python' iniciado por Stack, Outubro 7, 2024.

  1. Stack

    Stack Membro Participativo

    I'm working on creating assignments for students using Jupyter Notebooks. My goal is to generate different versions of the same Notebook to distribute to tutors and students.

    I need certain cells, such as those containing exercise solutions, to be included only in the tutor's version, while other cells should be exclusive to the student's version. Sometimes, I want to remove entire cells, and other times, just the output.

    I believe this can be achieved by tagging cells and using nbconvert to save the Notebook (.ipynb) into another .ipynb file.

    A similar method was suggested for converting .ipynb to HTML here. I'm interested in hearing if anyone has experience, or creative new ideas, in creating different versions of a single Jupyter Notebook for various audiences.

    My project is quite extensive, so I need an automated solution. While I could manually create different versions by copying and pasting if I only had a few Notebooks, this approach isn’t feasible for a larger scale.

    Following initial comments, I tried assigning the tag "remove_cell" to some of the Notebook cells (example notebook here) and then removing them using the suggestion of this answer

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


    However, the tagged cells are not removed when saving to Jupyter Notebook with the --to notebook option. They are only removed with the --to html option.

    Continue reading...

Compartilhe esta Página