[PYTHON] How to use Jupyter Notebook

Recently, I often use Jupyter Notebook for data analysis, so I have summarized how to use it. This article will be updated from time to time.

Before you start using

If you install it with Anaconda, the Jupyter Notebook itself will be ready to use. However, it is better to take the following measures for convenient use.

① Measures against garbled characters in matplotlib

If you do nothing, Japanese characters will be garbled, so install the Japanese font and apply it to Jupyter Notebook. Please refer to the following article for details. [Python] Japaneseize matplotlib

(2) Enable the extension "Table of Contents (2)"

The longer the note, the harder it is to find the part you want. So it's a good idea to install jupyter_contrib_nbextensions and enable the extension "Table of Contents (2)". Please refer to the following article for details. Make an oleore Python cheat sheet using the extension of Jupyter notebook

basic operation

Only the ones that are used frequently are extracted.

Common to edit mode / command mode

--Cell Execution: Ctrl-Enter --Execute cell → Select the cell below: Shift-Enter --Execute cell → Insert cell below: Alt-Enter --Save: Ctrl-s

Edit mode

--Transition to command mode: Esc --Interruption of running code: Ctrl-C --Tab completion: Tab with variable name, method name, etc. entered halfway --Object introspection (see general information about objects and docstrings): Before or after variables? Execute cell with

Command mode

--Transfer to edit mode: Enter --List of shortcut keys: h (in command mode) --Change cell to code: y --Change cell to markdown: m --Create heading with markdown: 1-6 --Add cell (above the selected cell): a --Add cell (below the selected cell): b --Cell copy: c --Cut cell: x --Paste cell (bottom): v --Paste cell (top): Shift-v --Delete cell (selected cell): dd --Find and Replace: f

Magic command

This is a command unique to Jupyter Notebook.

--% magic: Show detailed description of all magic commands --% time instruction (method, etc.): Measurement of instruction execution time --% timeit instruction (method, etc.): Measurement of instruction execution time (multiple times) * Effective for measuring instructions with extremely short execution time --% debug: Start from the bottom of the traceback for the last exception --% run Python filename Command line argument (optional): Start Python program --% who,% who_ls,% whos type name, variable name, etc .: Returns a list of variables of that type defined in the namespace in use (% who is a list,% who_ls is a list,% whos is a list. Return in a formatted list) --% reset: Remove names including variables from namespaces --% matplotlib inline: Display Matplotlib inline

Pandas related

--display function: If you use this instead of the print function, you can display with ruled lines.

Other

Sliding

You can use it by installing RISE with pip install rise.

References

--Wes McKinney (2018) "Introduction to Data Analysis with Python 2nd Edition -Data Processing with NumPy, pandas", O'Reilly Japan

Recommended Posts

How to use Jupyter Notebook
How to use jupyter notebook with ABCI
Jupyter Notebook Basics of how to use
Easy to use Jupyter notebook (Python3.5)
How to use xml.etree.ElementTree
How to use Python-shell
How to use tf.data
How to use virtualenv
How to use image-match
How to use shogun
How to use Pandas 2
How to use Virtualenv
How to use numpy.vectorize
How to use pytest_report_header
How to use partial
How to use Bio.Phylo
How to use SymPy
How to use x-means
How to use WikiExtractor.py
How to execute commands in jupyter notebook
How to use IPython
How to use virtualenv
How to use Matplotlib
How to use iptables
How to use numpy
How to use venv
How to use dictionary {}
How to use Pyenv
How to use list []
How to use python-kabusapi
How to use OptParse
How to use return
How to use pyenv-virtualenv
How to use Go.mod
How to use imutils
How to use import
How to use jupyter notebook without polluting your environment with Docker
How to debug with Jupyter or iPython Notebook
Jupyter Notebook Settings-How to use (EC2 Amazon Linux 2)
How to use Qt Designer
[IPython] How to Share IPython Notebook
How to use search sorted
[gensim] How to use Doc2Vec
python3: How to use bottle (2)
Understand how to use django-filter
How to use the generator
Use pip with Jupyter Notebook
[Python] How to use list 1
How to change Jupyter layout
How to use FastAPI ③ OpenAPI
How to use Python argparse
How to use Pandas Rolling
[Note] How to use virtualenv
Use Cython with Jupyter Notebook
How to use redis-py Dictionaries
Python: How to use pydub
[Go] How to use "... (3 periods)"
How to use Django's GeoIp2
[Python] How to use input ()
How to use the decorator
[Introduction] How to use open3d