드레:
코딩 뿌시기
드레:
전체 방문자
오늘
어제
  • 분류 전체보기 (268)
    • Python (74)
      • Python 기초 (42)
      • Numpy (8)
      • Pandas (22)
    • Machine Learning (31)
      • Machine Learning (1)
      • Deep Learning (27)
    • AWS (22)
      • RDS (3)
      • EC2 (9)
      • Lambda (8)
      • S3 (2)
    • MySQL (24)
    • Git (8)
    • Streamlit (12)
    • REST API (22)
    • Java (24)
    • Android (36)
    • Debugging (15)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • CNN
  • EC2
  • GET
  • pandas
  • Streamlit
  • JWT
  • github
  • serverless
  • fine tuning
  • AWS Lambda
  • 안드로이드 스튜디오
  • volley
  • 네이버 API
  • Ann
  • tensorflow
  • Retrofit2
  • Python
  • rest api
  • flask
  • Transfer Learning
  • aws s3
  • Java
  • Callback
  • AWS
  • 서버리스
  • API
  • 액션바
  • Lambda
  • 딥러닝
  • 깃이그노어

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
드레:

코딩 뿌시기

Pandas의 DataFrame.plot() 으로 시각화하기
Python/Pandas

Pandas의 DataFrame.plot() 으로 시각화하기

2022. 12. 1. 18:22

판다스 데이터프레임의 plot 메소드는

x축에 인덱스를 셋팅하고, y축에는 모든 컬럼의 데이터를 셋팅해준다.(모든 컬럼을 차트로 그려준다)

CCTV_result.csv
0.00MB

 

import pandas as pd
import matplotlib.pyplot as plt

# 한글처리코드
import platform
from matplotlib import font_manager, rc
plt.rcParams['axes.unicode_minus'] = False

if platform.system() == 'Darwin':
    rc('font', family='AppleGothic')
elif platform.system() == 'Windows':
    path = "c:/Windows/Fonts/malgun.ttf"
    font_name = font_manager.FontProperties(fname=path).get_name()
    rc('font', family=font_name)
else:
    print('Unknown system')
df = pd.read_csv('CCTV_result.csv', index_col=0)

 

df.plot()
plt.show()

 

 

 

# 원하는 컬럼만
df[['고령자', '외국인']].plot()
plt.show()

 

 

 

 

kind 파라미터를 사용해 다른 차트들도 그릴 수 있다.

 

The kind of plot to produce:

  • ‘line’ : line plot (default)
  • ‘bar’ : vertical bar plot
  • ‘barh’ : horizontal bar plot
  • ‘hist’ : histogram
  • ‘box’ : boxplot
  • ‘kde’ : Kernel Density Estimation plot
  • ‘density’ : same as ‘kde’
  • ‘area’ : area plot
  • ‘pie’ : pie plot
  • ‘scatter’ : scatter plot (DataFrame only)
  • ‘hexbin’ : hexbin plot (DataFrame only)

 

# bar
df[['외국인', '고령자']].plot(kind='bar')
plt.show()

 

 

 

# barh
df[['외국인', '고령자']].plot(kind='barh')
plt.show()

 

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

Pandas 피벗 테이블(Pivot table)  (0) 2022.12.01
오픈API Goolglemaps Geocode로 위치정보 받아오기  (0) 2022.12.01
pandas.read_csv() 콤마( , ) 가 포함된 수치형 컬럼 불러오기  (1) 2022.12.01
matplotlib, seaborn 을 활용한 데이터 시각화(4) - 히트맵, 한글처리  (0) 2022.11.30
matplotlib, seaborn 을 활용한 데이터 시각화(3) - scatter, regplot, pairplot, 상관계수  (0) 2022.11.30
    'Python/Pandas' 카테고리의 다른 글
    • Pandas 피벗 테이블(Pivot table)
    • 오픈API Goolglemaps Geocode로 위치정보 받아오기
    • pandas.read_csv() 콤마( , ) 가 포함된 수치형 컬럼 불러오기
    • matplotlib, seaborn 을 활용한 데이터 시각화(4) - 히트맵, 한글처리
    드레:
    드레:

    티스토리툴바