Crawling/데이터 시각화
데이터시각화_10가지_Box plot
km1n
2022. 1. 6. 17:18
파이썬 시각화 차트 종류
1. Column/Bar chart
2. Dual Axis, 파레토 chart
3. Pie chart
4. Line chart
5. Scatter chart
6. Bubble chart
7. Heat map
8. Histogram
9. Box plot
10. Geo chart
# 필요한 라이브러리 임포트
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from tqdm import tqdm_notebook
# 209.py
marathon_2015_2017 = pd.read_csv('./data_boston/marathon_2015_2017.csv')
print(marathon_2015_2017.shape)
marathon_2015_2017.head(3)
#미국인 참가자만 가져오기
USA_runner = marathon_2015_2017[marathon_2015_2017.Country =='USA']
print(USA_runner.shape)
USA_runner.head(3)
# 남녀 구분해서 데이터 저장
USA_MALE_runner = USA_runner[USA_runner['M/F'] == 'M']
USA_FEMALE_runner = USA_runner[USA_runner['M/F'] == 'F']
USA_MALE_runner.head(3)
# figure size 정하기
plt.figure(figsize=(10, 5))
# 씨본의 스타일 지정
sns.set(style='ticks', palette = 'pastel') # style = "ticks", "whitegrid" / palette = "pastel", "Set3"
# 박스플롯 그리기
sns.boxplot(x='M/F', y="Pace", palette=['b', 'r'], data=USA_runner)
실제 통계치 확인
USA_MALE_runner_stat = USA_MALE_runner['Pace'].describe()
USA_MALE_runner_stat