Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Jupyter Notebook: Specify cell execution order

I have a Jupyter notebook. In the cell 1, I defined a lot of functions, which need to run before other things. Then in the following cells, I start to present result. However, when I convert to HTML, this layout is ugly. Readers have to scroll a long time to see the result and they may not care about the functions at all. But I have to put the code in that order because I need those functions.

So my question is, is there a way I could control the run order of cells after I click run all? or is there a way I could do something like the following. I put all my function definitions in cell 20, then in cell 1, I could say tell Jupyter something like "run cell 20".

Just curious if this is doable. Thanks.

like image 448
JOHN Avatar asked Nov 19 '16 16:11

JOHN


1 Answers

I would save the functions as a separate module, then import this module at the beginning.

like image 166
Muhamed Al Khalil Avatar answered Sep 19 '22 12:09

Muhamed Al Khalil