Project Jupyter
Project Jupyter(지하철 공공데이터)-2024-06-18
앵보몬
2024. 6. 18. 13:11
728x90
반응형
승차 인원이 가장 많은 지하철역
import csv
f = open('subwaytime.csv')
data = csv.reader(f)
next(data)
next(data)
mx = 0
mx_station = ''
time = int(input('몇 시의 승차 인원이 가장 많은 역이 궁금하세요? : '))
for row in data :
row[4:] = map(int, row[4:])
a = row[4+(time-4)*2]
if a > mx:
mx = a
mx_station = row[3]+ '('+row[1]+')'
print(mx_station, mx)
하차 인원이 가장 많은 지하철역
import csv
f = open('subwaytime.csv')
data = csv.reader(f)
next(data)
next(data)
mx = 0
mx_station = ''
time = int(input('몇 시의 하차 인원이 가장 많은 역이 궁금하세요? : '))
for row in data :
row[4:] = map(int, row[4:])
a = row[5+(time-4)*2]
if a > mx:
mx = a
mx_station = row[3]+ '('+row[1]+')'
print(mx_station, mx)
시간대별 최대 승차 인원이 많은 지하철역
import csv
f = open('subwaytime.csv')
data = csv.reader(f)
next(data)
next(data)
mx = [0] * 24
mx_station = [0] * 24
for row in data :
row[4:] = map(int, row[4:])
for j in range(24):
a = row[j*2 + 4]
if a > mx[j]:
mx[j] = a
mx_station[j] = row[3]
import matplotlib.pyplot as plt
plt.rc('font', family = 'Malgun Gothic')
plt.title('시간대별 최대 승차 인원이 많은 지하철역')
plt.bar(range(24), mx, color = 'c' )
plt.xticks(range(24), mx_station, rotation = 90)
plt.ylabel("인구수")
plt.show()
시간대별 최대 하차 인원이 많은 지하철역
import csv
f = open('subwaytime.csv')
data = csv.reader(f)
next(data)
next(data)
mx = [0] * 24
mx_station = [0] * 24
for row in data :
row[4:] = map(int, row[4:])
for j in range(24):
b = row[5 + j*2]
if b > mx[j]:
mx[j] = b
mx_station[j] = row[3] + '('+str(j+4)+')'
import matplotlib.pyplot as plt
plt.rc('font', family = 'Malgun Gothic')
plt.title('시간대별 최대 하차 인원이 많은 지하철역')
plt.bar(range(24), mx, color = 'c' )
plt.xticks(range(24), mx_station, rotation = 90)
plt.ylabel("인구수")
plt.show()
728x90
반응형