A detailed introduction to the operation of Jupyter, an essential tool for data science

When it comes to data science, we have to say that it is a professional operation tool. The name Jupyter comes from the core supported programming languages ​​it supports: Julia, Python and R.

Jupyter Notebook is maintained by the folks at Project Jupyter. is an open source web application that can be used to create and share documents containing live code, equations, visualizations, and text. Is a spinoff of the IPython project, which used to have an IPython Notebook project itself.

Jupyter ships with an IPython kernel that allows programming in Python, but there are currently over 100 other kernels available.

insert image description here

Jupyter Notebook up and running

Jupyter Notebook is not included with Python, so it needs to be installed separately.

Installation tutorial can refer to

A nanny-level guide for IT beginners to install Python on various systems

Jupyter Notebook Server

Open the Terminal application and go to the folder of your choice and create a folder called Python Project or customize one.

terminal execution.
insert image description here
The default browser should launch (or open a new tab) to the following URL: http://localhost:8888/tree

Create notes

After starting the Notebook server, you can start creating notes.
insert image description here
A new web tab will pop up.
insert image description here

Naming Notes

At the top of the page is the word Untitled. This is the title of the page and the default name of the notebook, which can be modified.
insert image description here

run code unit

Add code to this cell.

print('Hello Jupyter!')

insert image description here
There is one that can be executed using Shift+Enter .

[n] to the left of the cell when running the cell. The square brackets are automatically populated with a number that indicates the order in which to run the cells. For example opening a new notebook and running the first cell at the top of the notebook, the square brackets will be filled with the number 1.

menu description

insert image description here

  • "File", you can create a new notebook or open a pre-existing notebook. This is also where the notebook is renamed. Menu item Save and Checkpoint This allows to create checkpoints that can be rolled back if needed.
  • "Edit", cut, copy and paste the cell content. Cells can also be deleted, split, or merged, and cells can be reordered here. Some items in this menu are grayed out because they don't apply to the currently selected cell.
  • "View", used to switch the title and toolbar. You can also turn row numbers within cells on or off.
  • "Insert", the Insert menu is only used to insert cells above or below the currently selected cell.
  • "Cell", allows to run a cell, a group of cells or all cells. The cell type can also be changed here. Another handy feature is the ability to clear the cell's output. Notes that are meant to be shared with others may need to clear the output first so the next person can run the cell themselves. Kernel units are used to handle kernels running in the background and can be restarted, reconnected, shut down, or even changed by the notebook being used by the kernel.
  • "Kernel", when debugging the notebook, you will find that you need to restart the kernel.
  • "Widgets", the widget menu is used to save and clear the widget state. Widgets are basically JavaScript widgets that can be added to cells to make dynamic content using Python (or other kernel).
  • "Help", you can learn about Notebook keyboard shortcuts, user interface tours and extensive reference materials.

Tab Operation Notes

When using Jupyter, remember not to close the shell command line window, you need to make sure that the data has been saved when closing.
insert image description here

Format/Operation Optimization

Jupyter Notebook supports adding rich content to its cells.

cell type

  • "Code", fill in the executable code.
  • "Markdown", all text formatting operations are replaced by Markdown, such as title making.
  • "Raw NBConvert", used to display code that does not run.
  • "Heading", directly converted into the title# format.

styled text

Jupyter Notebook supports Markdown, a markup language that is a superset of HTML.

Set the new cell to Markdown and add the following text to the cell.
insert image description here

Header

Use # to create headings, which can also be used to differentiate directory hierarchies.
insert image description here

Create a list

Use dashes (-), plus signs (+), or asterisks (*) to create lists.
insert image description here

Note export

Simply select the file type to export from the menu.
insert image description here

Notes extension

While Jupyter Notebooks has many features built in, new features can be added through extensions.

Extending the Nbextensions plugin

A Notebook extension (nbextension) is a JavaScript module that can be loaded in most views on the Notebook front end. If you're comfortable with JavaScript, you can even write your own extensions. Extensions can access the page's DOM and the Jupyter JavaScript API.

Command line installation.

conda install -c conda-forge jupyter_contrib_nbextensions
conda install -c conda-forge jupyter_nbextensions_configurator

After restarting the note, switch the home tab and select the note extension.

insert image description here

Guess you like

Origin blog.csdn.net/qq_20288327/article/details/124074390