코락 CoRock
코딩하는 락스타
코락 CoRock
  • 분류 전체보기 (393)
    • frameworks (19)
      • spring (19)
      • spring-boot (0)
      • testing (0)
    • languages (94)
      • java (39)
      • kotlin (0)
      • python (42)
      • r (13)
    • libraries (0)
    • programming (239)
      • android (13)
      • c (17)
      • cpp (22)
      • database (18)
      • design-pattern (4)
      • data-structures (11)
      • git (8)
      • hadoop (6)
      • html-css (7)
      • issue (4)
      • javascript (26)
      • jsp (34)
      • os (29)
      • php (6)
      • preferences (19)
      • etc (15)
    • discography (37)
      • k-pop (18)
      • pop (19)
    • blog (3)

블로그 메뉴

  • Programming
  • Java
  • JavaScript
  • Discography
  • K-Pop Songs
  • Pop Songs
  • Blog
  • Guestbook

공지사항

인기 글

태그

  • Spring
  • jsp
  • 파이썬
  • oracle
  • Java
  • python
  • r
  • javascript
  • linux
  • CentOS
  • 자바스크립트
  • Android

최근 댓글

최근 글

티스토리

반응형
hELLO · Designed By 정상우.
코락 CoRock

코딩하는 락스타

languages/python

[Python] 데이터 분석 라이브러리의 개요

2019. 4. 1. 09:23
반응형

23. 데이터 분석 라이브러리의 개요

 

23.1 Python의 주요 데이터 분석 라이브러리

23.1.1 넘파이(NumPy)

Python 데이터 분석의 기본적인 기능들을 제공

특히 벡터 및 행렬 연산과 관련된 편리한 기능들을 제공

 

23.1.2 판다스(Pandas)

Series, DataFrame 등의 자료 구조를 활용하여 데이터 분석에 있어 우수한 성능을 발휘함

대량의 데이터를 더욱더 빠른 속도로 처리할 수 있음

 

23.1.3 맷플롯립(Matplotlib)

데이터 분석 결과에 대한 시각화를 빠르고 직관적으로 수행

 

 

23.2 실습예제

# %: 매직 명령어
# 그래프 출력 과정을 볼 수 있도록 설정
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib

 

numpy.random.rand(d0)

# 50개의 난수 생성(0.0 ~ 1.0 사이의 값)
data = np.random.rand(50)
print(type(data))
print(data)

 

pandas.Series(data)

 

# NumPy 배열을 Pandas의 시리즈 자료형으로 변환(인덱스, 데이터의 조합)
seri = pd.Series(data)
print(type(data))
print(data)

 

# x축 인덱스 값, y축 랜덤 값
seri.plot()

 

# 그래프 스타일 변경
matplotlib.style.use("ggplot")

# 그래프 출력
seri.plot()

 

# rand(rows, cols)
# 10행 3열의 행렬
data_set = np.random.rand(10, 3)
print(data_set)
print(type(data_set))   # 변수의 자료형 확인
print(data_set.shape)   # 행렬의 차원 확인

 

# NumPy 행렬을 Pandas의 데이터프레임으로 변환
# 데이터프레임: 행과 열로 데이터를 조회할 수 있음
df = pd.DataFrame(data_set, columns=["A", "B", "C"])
# df
print(df)
print(type(df))

 

df.plot()

# 데이터프레임의 자료를 그래프로 출력
df.plot()

 

df.plot(kind="bar")

# 막대 그래프로 출력
df.plot(kind="bar")

 

# 수평 막대 그래프
df.plot(kind="barh")

 

# 누적 그래프
df.plot(kind="area")

 

df.plot(kind="area", stacked=False)

 

# 0.0 ~ 1.0 사이의 난수 발생
np.random.rand(5)

 

# NumPy의 랜덤 값 5개 => Pandas의 시리즈 자료형으로 변환
seri2 = pd.Series(\
    np.random.rand(5), index=["a", "b", "c", "d", "e"], name="series")
seri2.plot(kind="pie", autopct="%.2f", fontsize=20, figsize=(7, 5))

 

반응형
저작자표시 비영리 변경금지 (새창열림)
    'languages/python' 카테고리의 다른 글
    • [Python] Pandas
    • [Python] NumPy
    • [Python] 웹프로그래밍(상품관리)
    • [Python] 웹프로그래밍(게시판)
    코락 CoRock
    코락 CoRock
    A COder dreaming of being a ROCKstar

    티스토리툴바