0

Which one of the above should one use if they are just getting started?

Also, if there a way to quickly edit the code files while debugging to check specific portions of the code?

For example when you have a large file like this (publicly found).

If I decide to change a variable name (forecast_filled_df, input 25), do I then have to change it manually at all other locations or can I simply find all instances and replace all like you can do in text editors?

Essentially what I want to know is if there is a way to simply edit code in a separately generated file based on a given notebook without being distracted by all the outputs and having to scroll so much to specific locations.

smci
  • 32,567
  • 20
  • 113
  • 146
lbragile
  • 7,549
  • 3
  • 27
  • 64
  • 1
    Your question boils down to *"Does Jupyter have an IDE-like feature to (globally) change the name of a variable, within a notebook?"* – smci Nov 26 '19 at 21:58
  • More of should I create code in Jupyter or stick to my current editor and just use Jupyter to present my findings in a notebook style? – lbragile Nov 26 '19 at 21:59
  • But we don't know your current editor and even if we did that would be subjective, and quite possibly your decision could be *"Neither: use other IDE Z"*. Whereas asking *"Does editor/IDE X have feature Y?"* is objective. The bottom line is jupyter is a notebook, not a full IDE; I wouldn't try to manage 1000 lines of code with it. If you do large-scale development, either put your code in your own package, or use a proper IDE. – smci Nov 27 '19 at 01:02
  • Does this answer your question? [What is the difference between Jupyter Notebook and JupyterLab?](https://stackoverflow.com/questions/50982686/what-is-the-difference-between-jupyter-notebook-and-jupyterlab) – Henke Sep 19 '20 at 15:09

2 Answers2

2

I find jupyter notebook is good for viewing and editing a single notebook. However most of the time, I typically want to have access to multiple notebooks and files all at the same time, which jupyter lab is capable of. In any case, I don't see any reason to choose jupyter notebook over jupyter lab (+1 for dark mode).

The text editor built into jupyter lab is decent, but is definitely lacking compared to say sublime or vscode. If I'm editing code, I'm most definitely going to opt to use my favourite text editor and use it to only run and modify jupyter notebooks. It's good for rapidly prototyping python code, exploring data, or making quick models. This is especially useful if your a data scientist. You can always convert your jupyter notebook into a python script if you need to.

Also, you can use jupyter lab as a way to edit code via ssh, so if you're not familiar with vim or emacs, it's a good way to edit, explore, and upload/download files. You can also open up additional terminals in jupyter lab.

One issue you might run into using jupiter lab is that it crashes easily when you try to enter very large directories or open really large files from the GUI.

Unfortunately, I don't know of any way to find and replace within a notebook, however it's possible for text files using the text editor via cmd + d on mac.

Jay Mody
  • 3,727
  • 1
  • 11
  • 27
  • So from my understanding both are not really meant for code development but rather just for when you finish to "tell a story"? – lbragile Nov 26 '19 at 21:58
  • That's what I mainly use them for. However, they can be useful for isolating and reproducing bugs during development, especially if you have to instantiate a bunch of variables in a block of code. It's also easy to share a notebook that demonstrates a bug with other developers. – luthervespers Dec 13 '19 at 22:17
1

I think they omitted find and replace because you have to start a new session or execute all of the previous cells before the change is official. If you're in the middle of a huge session and just want to rename the variable, you could always add a cell with newvarname = oldvarname. If you don't mind starting a new jupyter session, you can open .ipynb files in a text editor and do a find and replace that way. This will also replace the variables if they appear in cached output.

luthervespers
  • 258
  • 1
  • 2
  • 10