Notice
Recent Posts
Recent Comments
05-10 20:29
Archives
관리 메뉴

develop myself

jupyter notebook magic commands, shell commands 본문

DataScience/Python

jupyter notebook magic commands, shell commands

insightous 2023. 1. 26. 15:12

magic commands

IPython의 기능. 즉, interactive 환경에서 사용한다.
주로 jupyter notebook에서 사용.

python 구문을 확장한 기능.
%로 시작하여 사용

  • line magics: %로 시작하여 사용. 한 문장을 실행.
  • cell magics: %%로 시작하여 사용. 한 셀을 실행

주요 magic commands

%matplotlib inline
# delete all variables in namespace
%reset
%run myscript.py
%timeit L = [n ** 2 for n in range(1000)]
%%timeit
L = []
for n in range(1000):
    L.append(n ** 2)

help

특정 magic command의 문서를 확인

%timeit?

magic command의 전반적인 문서 확인

%magic

사용가능한 magic command 확인

%lsmagic

공식 문서

shell commands

IPython의 기능.
UNIX/Linux commands를 interactive 환경에서 사용가능하게 하는 기능.
!로 시작하여 사용.

주요 shell commands

!ls
!pwd
!cat filename.txt

이외에도 많은 Linux 명령어들을 사용할 수 있다.

jupyter 공식문서

https://jupyter-tutorial.readthedocs.io/en/stable/workspace/ipython/shell.html

 

Shell commands in IPython - Jupyter Tutorial 0.9.0

Previous IPython magic

jupyter-tutorial.readthedocs.io

 

'DataScience > Python' 카테고리의 다른 글

matplotlib basic tips  (0) 2023.01.26
pandas basic tips  (0) 2023.01.26
numpy basic tips  (0) 2023.01.26
Python help, dir  (0) 2023.01.26
Python formatting: format() method, f-string  (0) 2023.01.25
Comments