본문 바로가기

IT To do and To was

22년 1월 8일_개인 small project made, python그래프

728x90
반응형

토요일[ㄱㅇ오라방이랑 수유, 교보, 스파이더맨, 전시회]

 

1. 택시운전사 나이에 따른 그래프, 시간대에 따른 택시 운영댓수_출처 : 서울 열린 데이터 광장

import requests
from bs4 import BeautifulSoup
import numpy as np
import matplotlib.pyplot as plt
import json
import re

response = requests.get("https://news.seoul.go.kr/traffic/archives/307")
html_doc = response.text

soup = BeautifulSoup(html_doc, "html.parser")
# print(soup)
soup.select('#post_content > table:nth-child(35) > tbody > tr:nth-child(3)')

timeuser_list = soup.select('#post_content > table:nth-child(35) > tbody > tr:nth-child(3)')

xpoint = []
ppoint = []
# print(timeuser_list)

for n in timeuser_list :
    # a = n.get_text.replace('\n',"")
    xpoint.append(n.get_text())


# xpoint.remove('개 인')
    
my_array = np.array(xpoint)

xpoints = np.array(['0시','2시','4시','6시','8시','10시','12시','14시','16시','18시','20시','22시'])
ypoints = np.array([36922, 15311, 12702, 23553, 47738, 42752, 40725, 43746, 46413, 44922, 45882, 47795])
apoints = np.array(['20대','30대','40대','50대','60대','70대','80대','90대','100대','110대','120대','130대'])
bpoints = np.array([3, 174,1825,9602,12674,13405,8069,2835,473,0,0,0])


# zpoints = np.array(my_array)
        
# np.savetxt("./data/score.csv",a)


plt.rc('font',family='Malgun Gothic')

plt.plot(xpoints, ypoints,'go-') #matplotlib라는 라이브러리에서 plot이라는 것으로 값을 넣음
plt.title('하루 평균 시간대별 영업건수 ')
plt.bar_label
plt.xlabel('하루 시간대')
plt.ylabel('영업건수')

plt.show()

plt.rc('font',family='Malgun Gothic')
plt.plot(apoints, bpoints, 'r-', label='line 2')
plt.title('21월 말 기준 종사자 나이')
plt.xlabel('나이대')
plt.ylabel('나이별 인원')

plt.show()

 

 

2. 사진 get!gg

 

728x90
반응형