Search code examples
pythonjupyter-notebookideeditorpython-interactive

JupyterLab vs. JupyterNotebook and how to edit code quickly


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.


Solution

  • 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.