Allow for nested Jupyter code cells
See original GitHub issueIt would be very useful to be able to nest Jupyter code calls based on indentation. This would make it possible to run for example just a part of a loop. For example:
# %% < -- top-level cell
j = 0
for i in range(10):
# %% < -- sub cell 1
print(i)
# %% < -- sub cell 2
for k in range(10):
# %% < -- sub sub cell 1
print(i * i)
# %% < -- sub cell 3
j += i
# %% < -- another top-level cell
print(j)
in this scenario triggering the outer cell would run the entire loop, while the inner cell would only run the code inside the loop.
This would be especially useful during data cleaning, where the processing step needs to be fine-tuned before being run on the whole dataset. If it makes the implementation more convenient, the inner cells could also be designated by adding additional percent characters for each nesting level, i.e.: # %%
- top-level cell, # %%%
- subcell, # %%%%
- subsubcell etc.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Can I nest cells in jupyter notebooks? - Stack Overflow
Is it possible to nest cells in a jupyter notebook? I would like to be able to collapse and expand sections of a...
Read more >Nest code-cells inside of admonitions and block-level syntax ...
Can I nest a code-cell under a dropdown cell? i.e. ... WARNING: Found an unexpected `code-cell` directive. Either this file was not converted...
Read more >Jupyter Notebook | Markdown | How to Add Nested List
In this tutorial we will learn how to add nested list for contents in Jupyter Notebook Markdown cell. Support If you find my...
Read more >Markdown Cells — Jupyter Notebook 6.5.2 documentation
Markdown basics . You can make text italic or bold by surrounding a block of text with a single or double *...
Read more >Markdown for Jupyter notebooks cheatsheet - IBM
You can use Markdown to format documentation you add to Markdown cells in your Jupyter notebook.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
While there is some slight overlap with #1471, the approach proposed here is significantly more flexible as it would allow for more incremental splits. Oftentimes, either the first or the last step in the loop is costly (i.e. getting/saving data) so being able to split it from the other steps would be quite useful.
Additionally, as mentioned in my previous comment, being able to specify blocks manually would be very useful in education as it would allow for creating step-by-step tutorials for students.
thanks for the suggestion, unfortunately I don’t think there is enough interest for us to prioritize this feature