1 분 소요

:octocat:Plot

Jupyter Notebook

  • Jupyter Extension
  • 결과창 줄이기
    더블클릭 / ESC + o
  • 도움말 shift + tab + tab

Plot

:pushpin: 시각화 할 때 데이터가 많으면 오래 걸린다. 속도를 개선 해보는 방법은?
대표값을 표시해야한다면 그래프에서 계산하지 않고 미리 계산해서 시각화 하기

matplotlib / koreanize-matplotlib

그래프에 retina display 적용
%config InlineBackend.figure_format = ‘retina’

  • Customizing Matplotlib with style sheets
    plt.style.use(“style”) # fivethirtyeight, ggplot 추천
    style 지정 - 기존 값들을 초기화 하지 않는다.
    => 다시 지정할 때 restart 해주는 게 편하다.

    plt.legend(bbox_to_anchor)
    secondary_y
    plt.axhline(val, color)

  • 로그 안뜨게 하는 방법
    plt.show(), 변수할당, ;

plotly

JavaScript 기반 동적

# plotly offline mode
from plotly.offline import iplot, init_notebook_mode
from plotly.subplots import make_subplots
init_notebook_mode()

color : seaborn의 hue처럼 색상에 따라 다른 데이터들을 구분해주는 역할을 하는 속성

오늘의 이모저모

  Series DataFrame 사용예
map O X df[“컬럼명”].map(함수 or dict)
apply O O df.apply(함수)
applymap X O df.applymap(함수)

벡터연산으로 반복문 보다 빠르다.
lambda를 사용해도 되지만, 가독성 떨어질 경우 함수를 사용하는 편이다.
tqdm의 progress_map

Series.to_list()
return a list of the values

merge/join

  • on : key
  • how inner / left / right / outer
    보통 right로 merge를 할 일이 있어도 left가 더 직관적이기 때문에
    두 데이터프레임의 순서를 바꿔주고 how=’left’를 많이 사용해주는 편

resample / 분할

cp949의 인코딩 범위에 아스키코드는 포함되지 않는다.


:bookmark:출처 - koreanize-matplotlib
https://github.com/ychoi-kr/koreanize-matplotlib
- matplotlib customizing
https://matplotlib.org/3.3.3/tutorials/introductory/customizing.html
- resampling
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.resample.html
https://pandas.pydata.org/docs/getting_started/intro_tutorials/09_timeseries.html#min-tut-09-timeseries


:mortar_board:포스팅 공지

작성한 포스팅은 멋쟁이 사자처럼 AI SCHOOl의 수업 내용입니다.

태그:

카테고리:

업데이트:

댓글남기기