Seaborn - Titanic Dataset ( histogram )

2024. 7. 6. 10:58·빅데이터 분석가 양성과정/Python
목차
  1. 연속값에 대한 구간별 도수 분포를 시각화
  2. seaborn histogram

    
python
#데이터 로드
import pandas as pd
titanic_df = pd.read_csv('titanic_train.csv')
titanic_df.head(5)

연속값에 대한 구간별 도수 분포를 시각화


    
python
### matplotlib histogram
import matplotlib.pyplot as plt
plt.hist(titanic_df['Age'])
#plt.show()

(array([ 54., 46., 177., 169., 118., 70., 45., 24., 9., 2.]),

array([ 0.42 , 8.378, 16.336, 24.294, 32.252, 40.21 , 48.168, 56.126,

64.084, 72.042, 80. ]),


    
python
# Pandas 에서 hist 함수를 바로 호출할 수 있음.
titanic_df['Age'].hist()

seaborn histogram

  • seaborn의 예전 histogram은 distplot함수지만 deprecate됨.
  • seaborn의 histogram은 histplot과 displot이 대표적이며 histplot은 axes레벨, displot은 figure레벨임.

    
import seaborn as sns
import warnings
warnings.filterwarnings('ignore')
#sns.distplot(titanic_df['Age'], bins=10)
sns.distplot(titanic_df['Age'], bins=10, kde =False)

 


    
import seaborn as sns
#import warnings
#warnings.filterwarnings('ignore')
sns.distplot(titanic_df['Age'], bins=10)
#sns.distplot(titanic_df['Age'], bins=10, kde =False)

    
### seaborn histogram
import seaborn as sns
# seaborn에서도 figure로 canvas의 사이즈를 조정
#plt.figure(figsize=(10, 6))
# Pandas DataFrame의 컬럼명을 자동으로 인식해서 xlabel값을 할당. ylabel 값은 histogram일때 Count 할당.
sns.histplot(titanic_df['Age'], kde=True)
#plt.show()

    
plt.figure(figsize=(12, 6))
sns.histplot(x='Age', data=titanic_df, kde=True, bins=30)

    
import seaborn as sns
# seaborn의 figure레벨 그래프는 plt.figure로 figure 크기를 조절할 수 없습니다.
#plt.figure(figsize=(4, 4))
# Pandas DataFrame의 컬럼명을 자동으로 인식해서 xlabel값을 할당. ylabel 값은 histogram일때 Count 할당.
sns.displot(titanic_df['Age'], kde=True, rug=True, height=4, aspect=2)
#plt.show()

    
plt.figure(figsize=(10, 6))
sns.distplot(titanic_df['Age'], kde=True, rug=True)

'빅데이터 분석가 양성과정 > Python' 카테고리의 다른 글

Seaborn - Tatanic Dataset(Violin plot)  (0) 2024.07.06
Seaborn - Titanic Dataset( barplot )  (0) 2024.07.06
Seaborn  (1) 2024.07.06
matplotlib(2)  (0) 2024.07.06
Matplotlib(1)  (0) 2024.07.06
  1. 연속값에 대한 구간별 도수 분포를 시각화
  2. seaborn histogram
'빅데이터 분석가 양성과정/Python' 카테고리의 다른 글
  • Seaborn - Tatanic Dataset(Violin plot)
  • Seaborn - Titanic Dataset( barplot )
  • Seaborn
  • matplotlib(2)
분석가 황규진
분석가 황규진
공공기관 위험평가관련 부서에서 근무하고 있습니다.
글쓰기 관리
분석가 황규진
HGJ's Insight
홈
|
로그인
  • 전체 글 563
    • 개인 활동(일상) 3
      • 독서 2
      • 근황 공유 1
    • 개인 활동(공부) 49
      • Tableau Bootcamp 10
      • 금융 공부 5
      • 직무 공부 22
      • 강의 12
    • 개인프로젝트 4
      • 신용카드 연체 평가 모델 0
      • 대출 승인 여부 예측 모델 4
    • 자격증 7
      • 빅데이터분석기사 1
      • 정보처리기사 1
      • 경영정보시각화 1
      • SQL개발자(SQLD) 1
      • 데이터 분석 준전문가(ADsP) 1
      • 통계적품질관리(SPC) 1
      • AICE Associate 1
    • 코드 정리 11
      • 코드 정리 - Tistory 8
      • 코드 정리 - Python 3
    • 코딩테스트연습 116
      • SQL_프로그래머스 116
    • 취업사관학교 9기 199
      • 모닝스쿨 54
      • 스스로 모닝스쿨 125
      • 직무 스터디 20
      • 반성과 다짐 0
    • 빅데이터 분석가 양성과정 173
      • Python 88
      • Python - 머신러닝 26
      • Python - 딥러닝 31
      • PyQt 4
      • JavaScript 10
      • MySQL 13
      • Node.js 1
hELLO· Designed By정상우.v4.6.1
분석가 황규진
Seaborn - Titanic Dataset ( histogram )
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.