- NewYork Times 읽기
- magic command
- TOC
- matplotlib 객제 지향 방식
- tistory toc
- tistory 목차
- jupyter notebook shell commands
- fig ax 사용
- 티스토리 자동 목차
- 티스토리 목차
목록DataScience (15)
develop myself
공식 문서 https://matplotlib.org/cheatsheets/ Matplotlib cheatsheets — Visualization with Python matplotlib.org cheatsheets https://matplotlib.org/cheatsheets/cheatsheets.pdf handout https://matplotlib.org/cheatsheets/handout-beginner.pdf https://matplotlib.org/cheatsheets/handout-intermediate.pdf https://matplotlib.org/cheatsheets/handout-tips.pdf
폰트 설정 import matplotlib.font_manager as fm # 설치된 폰트 출력 font_list = [ font.name for font in fm.fontManager.ttflist if font.name.startswith('Nanum')] font_list import matplotlib.pyplot as plt plt.rcParams['font.family'] = 'NanumGothic' plt.rcParams['font.family'] = 'Malgun Gothic' 이미지 저장 plt.savefig("filename") 이미지 output %matplotlib inline plt.show() minus error plt.rcParams['axes.unicode_minus']..
pandas.options.display jupyter notebook의 output 설정을 확인하고 변경할 수 있다. 설정 가능한 display 목록 확인 import pandas as pd # dir로 변경하고 싶은 설정 목록을 확인할 수 있음. dir(pd.options.display) 현재 설정 값 확인 # 현재 설정을 확인하고 싶을 경우 pd.get_option('display.max_rows') pd.get_option('display.max_columns') 설정 변경 pd.set_option('display.max_columns',None) pd.set_option('display.max_rows',None) # Pandas 숫자 출력 포맷팅 # https://financedata.gith..
ndarray numpy의 기본 데이터 타입. class 이다. ndarray 생성 함수 import numpy as np # ndarray 생성 a = np.array([1,2,3,4]) # ndarray 생성의 여러 예 b = np.zeros((3,3)) c = np.ones((3,4)) d = np.full((2,2),7) # 명시된 값으로 채우기 e = np.eye(3,3) f = np.random.random((2,2)) g = np.arange(5) 수학 함수 a = np.array([np.e, 2, 3]) np.abs(a) np.sqrt(a) np.log(a) np.floor(a) np.ceil(a) np.rint(a) # a에 가장 가까운 정수 를 나타내는 float 타입의 값을 반환 비교..
help 인터넷이 안 되는 상황에서 문서를 확인할 수 있다. import numpy as np import pandas as pd # class help(np.ndarray) # function help(np.array) help(pd.DataFrame) dir python object(class, method 등등)를 확인할 수 있다. dir(pd.DataFrame) 특정 조건을 만족하는 object를 찾을 경우 [ obj for obj in dir(pd.DataFrame) if ("na" in obj) & (not obj.startswith("_"))]
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의 문서..
.format() method 기본적인 방법 In [1]: 'We are the {} who say "{}!"'.format('knights', 'Ni') Out[1]: 'We are the knights who say "Ni!"' 순서 명시 In [2]: '{0} and {1}'.format('spam', 'eggs') Out[2]: 'spam and eggs' In [3]: '{1} and {0}'.format('spam', 'eggs') Out[3]: 'eggs and spam' 변수명 명시 In [4]: 'This {food} is {adjective}.'.format( food='spam', adjective='absolutely horrible') Out[4]: 'This spam is abs..