데이터 분석
2020년 전세계 인구 지표 (6) - 인구밀도 확인하기(P/Km²)
너굴맨_
2021. 12. 13. 09:53
1. 인구 밀도가 높은 국가 Top 10
2. 인구 밀도가 낮은 국가 Top 10
3. 구간화를 통해 시각화하기
4. 한국은?
해석
1. 대부분의 국가들은 1Km제곱당 0~150명 정도가 존재한다.
2. 인구 밀도가 높은 국가들은 모나코, 마카오, 싱가폴, 홍콩 등 작은 도시로 유명 관광지인 것을 확인할 수 있다.
3. 인구 밀도가 낮은 국가들은 북쪽에 위치한 국가로 사람이 살기에 척박한 지역임을 알 수 있다.
4. 한국은 1KM제곱 당 527명의 인구밀도를 가지며 이는 중국, 인도 보다 높은 수치이다.
코드
### 5.1 인구밀도 높은 국가 top 10
density = data[['Country','Density']].sort_values(by = 'Density', ascending=False)
density.head(10)
### 5.2 인구밀도 낮은 국가 top 10
density = data[['Country','Density']].sort_values(by = 'Density')
density.head(10)
### 5.3 구간화하여 살펴보자
bins = [-1,10,50,100,150,200,250,300,400,500,1000,10000,100000]
labels = ['0~10', '10~50', '50~100', '100~150', '150~200','200~250','250~300','300~400','400~500','500~1000','1000~10000','10000~']
den_bins = pd.cut(data['Density'], bins, right=True, labels=labels)
den_bins
count_den = den_bins.value_counts(sort=False)
plt.figure(figsize=(16,5))
bars = plt.bar(labels, count_den)
plt.xlabel('P/Km²')
plt.ylabel('Count')
# access the bar attributes to place the text in the appropriate location
for bar in bars:
yval = bar.get_height()
plt.text(bar.get_x() + 0.3, yval + 0.2, yval)
plt.show()
### 5.4 한국의 인구밀도는?
den_kor = density[density['Country'] == 'South Korea']
den_kor