pandas로 직접 시각화하기

R 사용자용 Python

Daniel Chen

Instructor

Python에서 시각화하기

  • 데이터 패턴을 빠르게 파악
  • Python 시각화 도구:
    • pandas
    • Seaborn
    • Matplotlib
R 사용자용 Python

pandas plot 메서드

  • plot() 메서드
  • pandas DataFrame 및 Series 객체에서 사용 가능
  • kind 인수를 전달
  • kind 옵션:
    • line : 선 그래프 (기본값)
    • bar : 수직 막대 그래프
    • barh : 수평 막대 그래프
  • hist : 히스토그램
  • box : 박스플롯
  • kde : 커널 밀도 추정 그래프
  • density : 'kde'와 동일
  • area : 면적 그래프
  • pie : 파이 그래프
  • scatter : 산점도
  • hexbin : 헥스빈 그래프
R 사용자용 Python

단변량: 히스토그램

import matplotlib.pyplot as plt
iris['sepal_length'].plot(kind='hist')
plt.show()

R 사용자용 Python

단변량: 막대 그래프

cts = iris['species'].value_counts()
cts.plot(kind='bar')
plt.show()

R 사용자용 Python

이변량: 산점도

iris.plot(kind='scatter', x='Sepal.Length', y='Sepal.Width')
plt.show()

R 사용자용 Python

이변량: 박스플롯

iris.plot(kind='box')
plt.show()

R 사용자용 Python

이변량: 박스플롯

iris.boxplot(by='Species', column='Sepal.Length')
plt.show()

R 사용자용 Python

연습해 봅시다!

R 사용자용 Python

Preparing Video For Download...