15 Tips and Tricks Jupyter Notebook
15 Tips and Tricks Jupyter Notebook
Image by from
Jupyter Notebook is a browser bases REPL (read eval print loop) built on IPython and other
open-source libraries, it allows us to run interactive python code on the browser.
It not only runs python code but also has many interesting plugins and magic commands
which enhances the python coding experience greatly.
1/12
2. Progress Bar:
One can use a python external library to create a progress bar, that can give live updates of
the progress of code. It keeps the user informed about the status of a running code script.
You can get the Github repository of library here.
The tqdm function can be used by importing its package and the usage and implementation
can be observed below:
nb_black is a simple extension for Jupyter Notebook and Jupyter Lab to beautify Python
code automatically.
2/12
pip3 install nb_black
%load_ext nb_black
4. Install Packages:
Jupyter Notebook can install any python package in the notebook itself. To install any python
package using the pip command in jupyter notebook cell enter a ! before the command.
For installing the pandas package: Enter ! pip install pandas and run the cell.
5. Documentation:
Jupyter Notebook can show that documentation of the function you are calling. Press
Shift+Tab to view the documentation. This is very helpful as you don’t need to open the
documentation website every single time. This feature also works for the local custom
3/12
functions.
Usage:
6. Autocomplete:
Jupyter Notebook can show suggestions for any function name or variable. To view
suggestions writing typing the code press Tab in your keyboard and the suggestion will
appear in a top-down menu. Press arrow-up or arrow-down key to scroll up or down the
menu. You can also scroll using your mouse. Click on the keyword or hit enter on the selected
keyword to confirm your suggestion.
You will also get suggestions for custom functions and variables.
4/12
(Image by Author), Suggestions from the pandas
package
You can repeat the process of a single click or double click to change the format of viewing
the output panel.
(Gif by Author), Click on the left side of the panel to change the view of the output screen
5/12
Jupyter Notebook has certain cell execution features that ease the programmer’s
performance.
Shit+Enter will run the current cell and highlight the next cell, if no cell is present it
will create a new cell.
Alt+Enter will run the current cell and insert a new cell and highlight it.
9. Markdown:
Jupyter notebook cells can not only run code snippets but also be used to write text.
Markdown cells can be used to write text descriptions. It is a better way to express than using
comments.
Usage:
6/12
()
%%bash
%%HTML
%%python2
%%python3
%%ruby
%%perl
7/12
11. Multiple Cursor:
Jupyter Notebook supports editing code using multiple cursors at once. To select the code to
edit at once press Alt key and select the code snippet using your mouse. After selection,
you can now edit the code using multiple cursors at once.
8/12
()
You can use that can create a multi-user Hub which spawns, manages, and proxies
multiple instances of the single-user Jupyter notebook server.
You can publish to medium directly from the jupyter notebook. Read to know the steps.
9/12
14. Plotting in Notebook:
Jupyter Notebook is the best tool used for data analysis and visualization. It can be used to
generate different types of plots using different python or R libraries. Some of the python
libraries used to generate plots are:
Jupyter Notebook also provides functionality to edit the keyboard shortcuts as per the
programmer’s convenience. You can edit keyboard shortcuts: Help>Edit Keyboard
Shortcuts .
10/12
(Image by Author), Command Mode Keyboard Shortcuts
11/12
Conclusion:
Jupyter Notebook is one of the best tools extensible used by folks working in the data science
domain due to interactive UI. The above-discussed 15 tips and tricks will help you to ease
your jupyter notebook coding experience. It has a lot more built-in magic commands that are
not discussed in this article, you can have a read here. Let me know your favorite tips and
comment if know more tricks.
12/12