출처: https://astrocosmos.tistory.com/202 [ASTROCOSMOS:티스토리] 데이터 분석_공모전_서울교육] 교직원 1인당 학생 수 :: 하나둘셋넷
728x90

https://data.seoul.go.kr/dataList/543/S/2/datasetView.do

 

열린데이터광장 메인

데이터분류,데이터검색,데이터활용

data.seoul.go.kr

 

 

import numpy as np
import pandas as pd
import csv
import matplotlib.pyplot as plt

data = pd.read_csv('./csv/교원+1인당+학생수(구별)_20230820151017.csv', index_col=0)

data_re = data.rename(columns=data.iloc[0])
data_re = data_re.drop(data.index[0])
data_re
print(data_re)

school_sort = list(set(list(data_re.index)))
print("\n\n학교 종류")
print(school_sort)

blank = []

for i in school_sort:

    a = data_re[data_re.index.str.contains(i)]    
    gyo = pd.DataFrame(a.loc[:,'교원1인당학생수'])
    gyo_nu = pd.to_numeric(gyo['교원1인당학생수'])
    gyo_nu_mean = gyo_nu.mean()
    
    blank.append(gyo_nu_mean)
    
print('\n\n')
print(blank)

plt.rcParams['font.family'] ='Malgun Gothic'
plt.rcParams['axes.unicode_minus'] =False

plt.bar(school_sort, blank)
plt.show()

 

 

728x90

+ Recent posts