Is It Possible to Read Values From Other Cells in Jupyter

15 Tips and Tricks for Jupyter Notebook that will ease your Coding Feel

Optimize your work in Jupyter Notebook using these hacks

Satyam Kumar

Jupyter Notebook is a browser bases REPL (read eval print loop) congenital on IPython and other open-source libraries, it allows united states of america to run interactive python code on the browser.

It not but runs python code but also has many interesting plugins and magic commands which enhances the python coding feel greatly.

1. Calculate the fourth dimension of execution of a cell:

One can calculate the time of execution of a jupyter notebook cell using magic command at the get-go of the cell. Information technology calculates the wall time that tin can be referred to equally the total fourth dimension required to execute that jail cell.

two. Progress Bar:

I tin can u s e a python external library to create a progress bar, that can give live updates of the progress of code. It keeps the user informed most the condition of a running code script. You can go the Github repository of library here.

First, you need to install tqdm library,

          pip3 install tqdm        

Or yous can also install it in a jupyter notebook cell using ! .

The tqdm function can exist used by importing its packet and the usage and implementation can exist observed beneath:

three. Automatic Code Formatter:

Using nb_black library, ane can format a code snippet in a cell to a proper format. Sometimes the code snippet in a jupyter notebook cell is not well-formatted, this library helps to accomplish proper formatting of the lawmaking snippet.

nb_black is a elementary extension for Jupyter Notebook and Jupyter Lab to beautify Python code automatically.

Installation of the library:

          pip3 install nb_black        

Usage for Jupyter Notebook:

          %load_ext nb_black        

(Image by Author), Unformatted cell

(Paradigm by Author), Formatted cell using nb_black

4. Install Packages:

Jupyter Notebook tin can install any python package in the notebook itself. To install any python package using the pip command in jupyter notebook prison cell enter a ! before the control.

For installing the pandas package: Enter ! pip install pandas and run the cell.

5. Documentation:

Jupyter Notebook can evidence that documentation of the function you lot are calling. Press Shift+Tab to view the documentation. This is very helpful as you don't demand to open the documentation website every single time. This feature also works for the local custom functions.

Usage:

  • Write the name of the office you want to implement
  • Press Shift+Tab to view the documentation.
  • Click on ^ on the meridian right corner of documentation to view it in a pager.
  • Click on + to grow the docstring vertically.
  • Click on x to shut the docstring.

(Epitome past Writer), Docstring for the pandas read_csv office

6. Autocomplete:

Jupyter Notebook can show suggestions for any function name or variable. To view suggestions writing typing the lawmaking press Tab in your keyboard and the suggestion will announced in a top-down menu. Press pointer-upwards or arrow-down key to scroll up or down the menu. Y'all tin can also scroll using your mouse. Click on the keyword or hit enter on the selected keyword to confirm your suggestion.

You will besides go suggestions for custom functions and variables.

(Epitome past Writer), Suggestions from the pandas parcel

7. Adjust the view of Output:

Jupyter Notebook tin impress the output of each jail cell only below the prison cell. When you take a lot of output you tin can reduce the amount of space it takes up by clicking on the left side panel of the output. This will plow the output into a scrolling window. Double click on the left side of the output to completely collapse the output panel.

You can repeat the process of a unmarried click or double click to change the format of viewing the output panel.

(Gif by Writer), Click on the left side of the console to modify the view of the output screen

8. Jail cell Execution Features:

Jupyter Notebook has certain jail cell execution features that ease the programmer's performance.

  • Shit+Enter will run the current cell and highlight the next cell, if no prison 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 just run code snippets just also be used to write text. Markdown cells tin can exist used to write text descriptions. It is a improve way to express than using comments.

Usage:

  • Click on the cell to convert it to markdown.
  • Cull the Markdown option from the drop-down bill of fare

(Paradigm past Author), Covert code jail cell to markdown cells

(Source)

x. Run code from different languages in the notebook:

Jupyter Notebook cells can likewise be used to compile and run code from different languages using IPython magic commands. Use IPython Magics with the name of your kernel at the offset of each cell that you want to use that cell for:

  • %%bash
  • %%HTML
  • %%python2
  • %%python3
  • %%ruby
  • %%perl

(Prototype by Author), HTML code snippet in jupyter notebook prison cell

11. Multiple Cursor:

Jupyter Notebook supports editing code using multiple cursors at once. To select the code to edit at once press Alt cardinal and select the code snippet using your mouse. Later on option, you can now edit the lawmaking using multiple cursors at once.

12. Creating Presentation from Jupyter Notebook:

Jupyter Notebook tin be used to create a PowerPoint-style presentation. Here each cell or grouping of cells of the notebook tin can be treated as each slide.

  • Firstly, install RISE using conda: conda install -c damianavila82 ascension
  • Enter/Exit RISE Slideshow button appears in the notebook toolbar. A slideshow option will also announced under View>Cell Toolbar>Slideshow
  • To prepare Slideshow click on View>Jail cell Toolbar>Slideshow and select the jupyter notebook cells for each slide.
  • Afterwards selecting each slide click on the RISE Slideshow button in the notebook toolbar.

Visit here for detailed video guide usage.

(Source)

thirteen. Share Jupyter Notebooks:

Later on code completion, you have several options to share your jupyter notebook.

  • Download your jupyter notebook as HTML, pdf, ipynb, py file, etc.

  • You tin can use JupyterHub that can create a multi-user Hub which spawns, manages, and proxies multiple instances of the single-user Jupyter notebook server.
  • Yous can publish to medium directly from the jupyter notebook. Read this to know the steps.

14. Plotting in Notebook:

Jupyter Notebook is the best tool used for data analysis and visualization. Information technology can be used to generate dissimilar types of plots using different python or R libraries. Some of the python libraries used to generate plots are:

  • Matplotlib
  • Seaborn
  • bokeh
  • plot.ly

(Source), Different types of plots

fifteen. Keyboard Shortcuts:

Shortcuts are used to save a lot of developer'southward time and ease the coding experience. Jupyter notebook has plenty of inbuilt keyboard shortcuts that you observe nether the Help menu bar: Help>Keyboard Shortcuts .

Jupyter Notebook also provides functionality to edit the keyboard shortcuts as per the developer's convenience. Y'all can edit keyboard shortcuts: Assist>Edit Keyboard Shortcuts .

(Image by Author), Command Mode Keyboard Shortcuts

(Image by Author), Edit Style Keyboard Shortcuts

Determination:

Jupyter Notebook is one of the best tools extensible used by folks working in the data scientific discipline domain due to interactive UI. The higher up-discussed xv tips and tricks volition assist you to ease your jupyter notebook coding experience. It has a lot more than built-in magic commands that are non discussed in this commodity, y'all can accept a read hither. Let me know your favorite tips and annotate if know more tricks.

  • The images used in the article are either cited or generated by the author

Thank you for Reading

shawfainjusly.blogspot.com

Source: https://towardsdatascience.com/15-tips-and-tricks-for-jupyter-notebook-that-will-ease-your-coding-experience-e469207ac95c

Artikel Terkait

Belum ada Komentar untuk "Is It Possible to Read Values From Other Cells in Jupyter"

Posting Komentar

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel