Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- pandas
- 딥러닝
- XOR게이트
- 비지도학습
- seaborn
- 머신러닝
- 리눅스
- NAND게이트
- 파이썬
- 판다스
- linux
- 데이터분석
- 선형회귀
- DataFrame
- 씨본
- python
- ubuntu
- 크롤링
- OR게이트
- AND게이트
- 데이터시각화
- 로지스틱회귀
- 데이터크롤링
- Deeplearning
- numpy
- 달의조각
- 퍼셉트론
- 우분투
- 데이터프레임
- Perceptron
Archives
- Today
- Total
Charming ['ㅡ'] Ham !
Python | 시계열 데이터 시각화 본문
728x90
반응형
728x90
시계열 데이터 시각화¶
1. 데이터 가져오기¶
가져올 데이터 주소
$ wget https://aiffelstaticprd.blob.core.windows.net/media/documents/flights.csv
In [26]:
# 패키지 가져오기
import os
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
In [27]:
# 데이터 가져오기
csv_path = os.getenv('HOME') + '/data_represent/data/flights.csv'
data = pd.read_csv(csv_path)
flights = pd.DataFrame(data)
flights
Out[27]:
year | month | passengers | |
---|---|---|---|
0 | 1949 | January | 112 |
1 | 1949 | February | 118 |
2 | 1949 | March | 132 |
3 | 1949 | April | 129 |
4 | 1949 | May | 121 |
... | ... | ... | ... |
139 | 1960 | August | 606 |
140 | 1960 | September | 508 |
141 | 1960 | October | 461 |
142 | 1960 | November | 390 |
143 | 1960 | December | 432 |
144 rows × 3 columns
In [28]:
# 연도의 각 년도 별 탑승객 수 시각화
# 막대 그래프
sns.barplot(data = flights, x = 'year', y = 'passengers')
Out[28]:
<AxesSubplot:xlabel='year', ylabel='passengers'>
In [29]:
# 선 그래프 (각 수치 별 점으로 표시)
sns.pointplot(data = flights, x = 'year', y = 'passengers')
Out[29]:
<AxesSubplot:xlabel='year', ylabel='passengers'>
In [30]:
# 선그래프
sns.lineplot(data = flights, x = 'year', y = 'passengers')
Out[30]:
<AxesSubplot:xlabel='year', ylabel='passengers'>
In [31]:
# 월 별 구분을 위해 hue 인자에 month 할당
sns.lineplot(data = flights, x = 'year', y = 'passengers', hue = 'month', palette = 'ch:.50')
# 그래프 밖에 레전프 추가
plt.legend(bbox_to_anchor = (1.03, 1), loc = 2)
Out[31]:
<matplotlib.legend.Legend at 0x7ffbaac4b0d0>
In [39]:
# 히스토그램을 통한 시각화
# seaborn 은 displot 가 히스토그램을 뜻한다.
sns.displot(flights['passengers'], kde = True)
Out[39]:
<seaborn.axisgrid.FacetGrid at 0x7ffbaa66c590>
In [ ]:
728x90
반응형
'지식 정보 공유 > 코딩 : Coding' 카테고리의 다른 글
Python | 판다스를 활용한 데이터 탐색, 데이터 분석 (EDA) (0) | 2021.01.23 |
---|---|
Python | Heatmap, 데이터 시각화 (0) | 2021.01.22 |
Python | 데이터 시각화하기 / Visualization (0) | 2021.01.20 |
Python |구조화된 데이터(딕셔너리, 판다스, 데이터프레임) (0) | 2021.01.15 |
Python | CSV 파일과 CSV파일 읽고, 쓰기 (0) | 2021.01.15 |