What is Jupyter Notebook and how to use it

1. What is Jupyter Notebook?

The Jupyter project is a non-profit open source project derived from the python project in 2014.

  • Juptter Notebook, formerly known as IPython Notbook, is an enhanced web version of IPython, an open source web application
  • Names derived from Julia, Python and R
  • It is a programming/documentation/note-taking/presentation software for programmers and scientific workers
  • The .ipynb file format is the formal specification for a JSON document format for computational narratives.
    The Juptyter project aims to develop open source software, open standards, and services for interactive computing across dozens of programming languages.

2. Why use Juypter Notebook?

  • Traditional Software Development: Engineering/Clear Goals
    • Requirements analysis, design architecture, development modules, testing
  • Data Mining: Art, Ambiguous Goals
    • The purpose is to gain specific insight into the goal, not to complete the task mechanically.
    • Solve problems by executing code
    • Iteratively improve code to improve solutions.
      Live-running code, narrative text, and visualizations are integrated to make it easy to tell stories using code and data.
      Compare Jupyter Notebook and Pycharm
  • Draw a picture
import matplotlib.pyplot as plt

plt.figure(figsize=(20, 8), dpi=100)
plt.plot([1,2,3], [4,5,6])
plt.show()

Insert image description here

  • Data Display
import pandas as pd
stock_day = pd.read.csv("./stock_day/stock_day.csv")

Summary: Jupyter Notebook has advantages over Pycharm in drawing and data display.

3. How to use Jupyter Notebook

pip install jupyter notebook
pip install matplotlib numpy pandas three packages.
After installation, in the command line window, enter
jupyter notebook
and the page will automatically jump to http://localhost:8888/tree
Insert image description here

Then create a new notebook document. The document format of notebook is .ipynb
Insert image description here1. Content interface operation
Title bar: Click on the title (such as Untitled) to modify the document name.
Edit bar: print("hello world")

2. Mouse operations
Insert image description here
: save, insert cell, cut cell, copy cell, paste cell, move cell up, move cell down, execute cell, interrupt cell execution, restart Python kernel, cell classification mode code/Markdown, console
Cell refers to a unit of code.

3. Shortcut key operation
The common shortcut key Shift+Enter in both modes
is to execute the code of this unit and jump to the next unit.
Ctrl+Enter, execute the code of this unit and stay in this unit.
Command mode: Press ESC to enter
Y, the cell switches to Code mode
M, the cell switches to Markdown mode
A, add cell B above the current cell
, and add cell below the current cell.

4. Markdown demonstration.
You can use ESC, then M, to switch to Markdown mode
Insert image description here
Insert image description here
5. Jupyter Notebook automatic code completion function expansion
5.1 Install Jupyter_contrib_nbextensions library
installation command

python -m pip install jupyter_contrib_nbextensions

and then execute

jupyter contrib nbextension install --user --skip-running-check

Then check Table of Contents and Hinterland
Insert image description here

Guess you like

Origin blog.csdn.net/qq_30353203/article/details/131197322