这是用户在 2025-6-4 20:56 为 https://app.immersivetranslate.com/pdf-pro/fbc730e8-dab9-4196-9f77-fc0a6e6c20ef/ 保存的双语快照页面,由 沉浸式翻译 提供双语支持。了解如何保存?

우리동니 인구구조 시각화하기   我们社区人口结构可视化

소프트웨어학부 진혜진  软件学部 陈惠珍

1. 인구 공공데이터 내려받기
1. 下载人口公共数据

2. 인구 데이터 살펴보교 질문하기
2. 解读人口数据并提出问题

3. 우리 동네 인구 구조 시각화하기
3. 我们社区人口结构可视化

  • 어떤 단계를 거쳐야 할지 생각해 보자.
    让我们思考需要经历哪些步骤。

    -인구 데이터 파일을 읽어 온다.
    -读取人口数据文件。

    -전체 데이터에서 한 줄씩 반복해서 읽어온다.
    -从整体数据中逐行循环读取。

    -우리 동네에 대한 데이터인지 확인한다.
    -确认是否属于我们社区的数据。

    "우리 동네일 경우 0세부터 100세 이상까지의 인구수를 순서대로 저장한 다.
    "以我们社区为例,将 0 岁至 100 岁及以上的人口数按顺序存储。

    -저장된 연령별 인구수 데이터를 시각화 한다.
    - 将存储的各年龄段人口数据进行可视化。

우리 뭉내 인구 구좃 시긱형하
我们社区人口结构图形化

우리 동네 0~100 세이상 인구 수를 리스트로 츨력하기
将我们社区 0~100 岁及以上人口数以列表形式输出

from google.colab import files
upload = files.upload()

파일 선택 age.csv  选择文件 age.csv

  • age.csv(text/csv) - 1593070 bytes, last modified: 2025. 6. 4. - 100% done
    age.csv(text/csv) - 1593070 字节,最后修改时间:2025 年 6 月 4 日 - 已完成 100%
Saving age.csv to age (1).csv
将 age.csv 另存为 age (1).csv

import csv  导入 csv 模块
\square B C D E F
1 행정구역  行政区划 7 2025년04월_계_연령구간인구수  2025年04月_合计_各年龄段人口数 - 2025년04월_계_0세  - 2025 年 04 月_总计_0 岁 \checkmark 2025년04월_계_2세  2025年04月_合计_2岁
◻ B C D E F 1 행정구역 7 2025년04월_계_연령구간인구수 - 2025년04월_계_0세 ✓ 2025년04월_계_2세| | $\square$ | B | C | D | E | F | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | 1 | 행정구역 | 7 | 2025년04월_계_연령구간인구수 | - 2025년04월_계_0세 | $\checkmark$ | 2025년04월_계_2세 |
file = open(‘age.csv’, encoding = ‘cp949’) #파일 열기
file = open('age.csv', encoding = 'cp949') #打开文件

age = csv.reader(file) #파일 읽기
age = csv.reader(file) #读取文件

result = []
for i in age: #파일 처리
for i in age: #处理文件

if ‘종암동’ in i[0]:
if '종암동' in i[0]:

for j in i[3:]:
result.append(int(j))
print (result)
  • 연령별 인구수가 숫자 값으로 잘 저장되었네요.
    各年龄段人口数已成功存储为数值格式。
  • 이제 데이터를 시각화하기만 하면 된다.
    现在只需将数据可视化即可。

    -matplotlib 라이브러리로 임포트하교, 데이터를 시각화하기에 적합한 그 래프 종류를 선택하교, showld함수로 보여주면 된다.
    - 导入 matplotlib 库,选择合适的图表类型进行数据可视化,并用 show 函数展示。
  • 데이터를 그래프로 표현하면 덱스트로 표현했을 때보다 데이터를 직관적으로 이 해할 수 있음
    将数据以图表形式呈现时,相比纯文本更能直观理解数据。
  • 데이터가 변화하는 흐름을 한눈에 파악할 수 있어 현재 상황을 이해하기 쉬울 뿐 아니라, 앞으로의 변화 추이까지 예측할 수 있게 도와줌
    不仅能一眼看清数据变化的趋势,便于理解现状,还能帮助预测未来的变化走向。

    " plot 함수에 기본 그래프를 그릴 때 순서
    绘制基础图表时 plot 函数的顺序

    -1. 라이브러리 불러오기  -1. 导入库
  • import matplotlib.pyplot as plt
    -2. plot()함수에 데이터 입력하기
    -2. 向 plot()函数输入数据
  • plt.plot(리스트 이름)  plt.plot(列表名称)
    -3. 그래프 보여주기  -3. 显示图表
  • plt.show()

우리 뭉내 인구 구좃 시긱형하
我们小区人口结构可视化

  • 주의!!  注意!!
    -구글 코랩에서 시각화를 하면 한글 깨짐이 발생할 수 있다.
    -在 Google Colab 中进行可视化时可能会出现韩文乱码问题。

    -폰트 설치(nanum 폰트)   -需安装字体(nanum 字体)
    Isudo apt-get install -y fonts-nanum
    Isudo fc-cache -fv  sudo fc-cache -fv
    Irm ~/.cache/matplotlib -rf
    rm ~/.cache/matplotlib -rf

우리 명내 인구 구좃 시각화히니
可视化我们社区的人口结构

폰트 설치  安装字体

!sudo apt-get install -y fonts-nanum
!sudo fc-cache -fv
!rm ~/.cache/matplotlib -rf
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
    fonts-nanum
0 upgraded, 1 newly installed, 0 to remove and 35 not upgraded.
Need to get 10.3 MB of archives.
After this operation, 34.1 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu jammy/universe amd64 fonts-nanum all 20200506-1 [10.3 MB]
Fetched 10.3 MB in 0s (22.6 MB/s)
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like progran /root/.local/share/ronts: Skipping, no such directory
    /root/.fonts: skipping, no such directory
        /usr/share/fonts/truetype: skipping, looped directory detected
    /usr/share/fonts/truetype/humor-sans: skipping, looped directory detected
    /usr/share/fonts/truetype/liberation: skipping, looped directory detected
    /usr/share/fonts/truetype/nanum: skipping, looped directory detected
    /var/cache/fontconfig: cleaning cache directory
    /root/.cache/fontconfig: not cleaning non-existent cache directory
    /root/ fontconfia: not cleaning non-existent cache directory
    fc-cache: succeeded

우리 명내 인구 구좃 시각화히니
我们社区人口结构可视化

[7] from google.colab import files
upload = files.upload()
파이ᄅ 서ᄂ태ᄀ age.csv
- age.csv(text/csv) - 1593070 bytes, last modified: 2025. 6. 4. - 100% done
Saving age.csv to age (1).csv
[11] !sudo apt-get install -y fonts-nanum
!sudo fc-cache -fv
!rm ~/.cache/matplotlib -rf
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
fonts-nanum is already the newest version (20200506-1).
O upgraded, O newly installed, O to remove and 35 not upgraded.

우리 명내 인구 구좃 시각화히니
我们社区人口结构可视化

우리 뭉내 인구 구존 시각형하
我们社区人口结构可视化

#시각화하기
import matplotlib.pyplot as plt
plt.rc(‘font’, family=‘NanumBarunGothic’)
plt.rc('font', family='NanumBarunGothic')

plt.title(‘종암동 인구구조’)  plt.title('钟岩洞人口结构')
plt.plot(result)
plt.show()
[ 141 , 145 , 138 , 139 , 186 , 174 , 201 , 198 , 240 , 268 , 298 , 284 , 331 , 289 , 324 , 313 , 312 , 350 , 332 , 377 , 469 , 454 [ 141 , 145 , 138 , 139 , 186 , 174 , 201 , 198 , 240 , 268 , 298 , 284 , 331 , 289 , 324 , 313 , 312 , 350 , 332 , 377 , 469 , 454 [141,145,138,139,186,174,201,198,240,268,298,284,331,289,324,313,312,350,332,377,469,454[141,145,138,139,186,174,201,198,240,268,298,284,331,289,324,313,312,350,332,377,469,454
종암동 인구구조  钟岩洞人口结构

우리 명내 인구 구좃 시각화히니
我们社区人口结构可视化


import matplotlib.pyplot as plt
plt.rc(‘font’, family=‘NanumBarunGothic’)
plt.rc('font', family='NanumBarunGothic')

plt.title(‘종암동 인구구조’)  plt.title('钟岩洞人口结构')
plt.plot(result, color =‘red’)
plt.plot(result, color='red')

plt.xlabel(‘연령대’)  plt.xlabel('年龄段')
plt.ylabel (‘인구수’)  plt.ylabel('人口数')
plt.legend([‘종암동’])  plt.legend(['钟岩洞'])
plt.show( )
종암동 인구구조  钟岩洞人口结构

[ ] from google.colab import files
upload = files.upload()
고 파일 선택 age.csv
选择文件 age.csv
  • age.csv(text/csv) - 1593070 bytes, last modified: 2025. 6. 4. - 100 % 100 % 100%100 \% done
    age.csv(文本/csv) - 1593070 字节,最后修改时间:2025 年 6 月 4 日 - 100 % 100 % 100%100 \% 完成
Saving age.csv to age (1).csv
将 age.csv 保存为 age (1).csv

!sudo apt-get install -y fonts-nanum
!sudo fc-cache -fv
!rm ~/.cache/matplotlib -rf
Э  Э  ⇆_(" Э ")\underset{\text { Э }}{\leftrightarrows}Э
Reading package lists… Done
正在读取软件包列表… 完成

Building dependency tree… Done
正在构建依赖树… 完成

[8] import csv
file = open('age.csv',encoding = 'cp949') #파이ᄅ 여ᄅ기
age = csv.reader(file) #파이ᄅ 읽기
result = []
for i in age: #파이ᄅ 처리
    if '조ᄋ아ᄆ도ᄋ' in i[0]:
        for j in i[3:]:
            result.append(int(j))
print(result)
#시가ᄀ화하기
import matplotlib.pyplot as plt
plt.rc('font',family='NanumBarunGothic')
plt.title('조ᄋ아ᄆ도ᄋ 이ᄂ구구조')
plt.plot(result, color ='red')
plt.xlabe|('여ᄂ려ᄋ대')
plt.ylabel('이ᄂ구수')
plt.legend(['조ᄋ아ᄆ도ᄋ'])
plt.show()

우리 동내 인구 구조 시각화하비
可视化我们社区的年龄结构

  • 기말대체 과제  期末替代作业
    -내가 살고 있는 동네의 인구구조 시각화하기
    - 我所居住社区的年龄结构可视化

    -파일 제목 : 기말대체과제_몬인이름_본인동네
    - 文件标题:期末替代作业_姓名_所在社区

    -제출 파일 : .jpynb파일
    - 提交文件:.jpynb 文件

    -제출 마감일 : 6월 10일
    - 提交截止日期:6 月 10 日

    -6월 6일까지 제출시 보너스 +2점 부여
    -6 月 6 日前提交可获额外加分 2 分
  • 단, 완벽하게 했을 때만 부여
    但仅限完美完成的情况