0

I am working in jupyter notebook and I have more than 100 cells doing different operations on data but depending on my need I want to run just around 25 different cells in every case.

example:

Run cell 20 then 26 then 79 then 43 then do the current cell's code.

Is this even healthy code, or maybe I should rerun over cells and turn them all into functions, maybe.

slimguat
  • 45
  • 5
  • 1
    this sounds like a bad plan. :). One of the key tenets of data science is reproducibility and having a "click plan" on cells isn't it. As you suggested, I would encapsulate things into functions and in the "execution area" set it up with a sequence of function calls in any particular cell. My 2 cents. – AirSquid May 20 '21 at 14:17
  • 1
    It sounds that what you need is a specialised kernel like https://github.com/nbsafety-project/nbsafety or https://github.com/dataflownb/dfkernel. – krassowski May 20 '21 at 14:21
  • 1
    But also, you could build a JupyterLab extension that executes cells based on their number. It should be easy. – krassowski May 20 '21 at 14:22
  • well thanks in fact the main problem is that i have already defined my own functions also but when i call them once for testing and after a modification of these external functions and I recall an import for them it doesn't import what's already imported so i have to restart the kernal and rerun over all the cells again and again for every modification i do in the external function. – slimguat May 20 '21 at 14:29
  • 1
    This is a very different problem. This just means that you need to enable auto-reload: https://stackoverflow.com/questions/5364050/reloading-submodules-in-ipython – krassowski May 20 '21 at 14:36
  • Agree this is not a great idea. The only viable use case for Jupyter notebooks is EDA. In my opinion, everything else should be in an IDE like PyCharm, writing base Python scripts. – Adrian Keister May 20 '21 at 15:38

0 Answers0