Skip to content
Snippets Groups Projects
Commit bcc569b4 authored by Wonjong Jeong's avatar Wonjong Jeong
Browse files

first commit

parents
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id: tags:
``` python
import requests
import json
import pandas as pd
import datetime
url = "http://openapi.seoul.go.kr:8088/73684163486a776a3132326465784c67/json/bikeList/1/1000/" #1000개단위
response = requests.get(url)
bikeData1=(response.json()["rentBikeStatus"])["row"]
url = "http://openapi.seoul.go.kr:8088/73684163486a776a3132326465784c67/json/bikeList/1001/2000/" #1000개단위
response = requests.get(url)
bikeData2=(response.json()["rentBikeStatus"])["row"]
bikeData=bikeData1+bikeData2 #합침
type(bikeData)
pd.DataFrame(bikeData)
```
%% Output
rackTotCnt stationName parkingBikeTotCnt shared \
0 22 102. 망원역 1번출구 앞 0 0
1 16 103. 망원역 2번출구 앞 4 0
2 15 104. 합정역 1번출구 앞 0 0
3 7 105. 합정역 5번출구 앞 1 0
4 12 106. 합정역 7번출구 앞 1 0
... ... ... ... ...
1707 10 3553.마장역3번출구 0 0
1708 10 3555.양지사거리(센트라스APT 115동앞) 0 0
1709 10 3558.마장동 금호어울림APT앞 0 0
1710 10 3559.성동구민종합체육센터 앞 0 0
1711 10 3560.성동구 견인차량 보관소 앞 0 0
stationLatitude stationLongitude stationId
0 37.55564880 126.91062927 ST-4
1 37.55495071 126.91083527 ST-5
2 37.55062866 126.91498566 ST-6
3 37.55000687 126.91482544 ST-7
4 37.54864502 126.91282654 ST-8
... ... ... ...
1707 37.56597900 127.04311371 ST-2335
1708 37.56681824 127.02915192 ST-2337
1709 37.56339645 127.04187012 ST-2340
1710 37.54590988 127.04460144 ST-2341
1711 37.56370926 127.05644989 ST-2342
[1712 rows x 7 columns]
%% Cell type:code id: tags:
``` python
url = "http://openapi.seoul.go.kr:8088/614969636b6a776a38316576544973/json/TimeAverageAirQuality/1/25/"
today=str(datetime.datetime.today().strftime("%Y%m%d%H")+"00"); #한시간단위로 갱신
response=requests.get(url+today)
if "TimeAverageAirQuality" in response.json():
airData=(response.json()["TimeAverageAirQuality"])["row"]
else: #현재 데이터가 없는경우 한시간 전 데이터 사용
today=(datetime.datetime.today()-datetime.timedelta(hour=1)).strftime("%Y%m%d%H")+"00"
response=requests.get(url+today)
airData=(response.json()["TimeAverageAirQuality"])["row"]
pd.DataFrame(airData)
```
%% Output
MSRDT MSRSTE_NM NO2 O3 CO SO2 PM10 PM25
0 202006032000 강남구 0.021 0.050 0.4 0.003 52.0 28.0
1 202006032000 강동구 0.022 0.042 0.4 0.003 63.0 29.0
2 202006032000 강북구 0.014 0.041 0.4 0.003 56.0 27.0
3 202006032000 강서구 0.013 0.037 0.4 0.004 38.0 19.0
4 202006032000 관악구 0.019 0.043 0.5 0.003 47.0 19.0
5 202006032000 광진구 0.020 0.062 0.4 0.003 55.0 26.0
6 202006032000 구로구 0.012 0.052 0.3 0.002 36.0 15.0
7 202006032000 금천구 0.018 0.027 0.4 0.002 38.0 21.0
8 202006032000 노원구 0.018 0.047 0.5 0.003 60.0 26.0
9 202006032000 도봉구 0.019 0.059 0.4 0.005 60.0 21.0
10 202006032000 동대문구 0.027 0.044 0.5 0.004 49.0 22.0
11 202006032000 동작구 0.017 0.038 0.4 0.002 50.0 20.0
12 202006032000 마포구 0.021 0.040 0.5 0.003 38.0 20.0
13 202006032000 서대문구 0.021 0.046 0.6 0.003 60.0 19.0
14 202006032000 서초구 0.017 0.057 0.3 0.004 64.0 14.0
15 202006032000 성동구 0.020 0.046 0.4 0.003 50.0 23.0
16 202006032000 성북구 0.029 0.045 0.7 0.003 0.0 36.0
17 202006032000 송파구 0.023 0.054 0.5 0.003 54.0 22.0
18 202006032000 양천구 0.019 0.030 0.5 0.003 45.0 20.0
19 202006032000 영등포구 0.019 0.045 0.4 0.003 41.0 20.0
20 202006032000 용산구 0.016 0.038 0.4 0.002 52.0 19.0
21 202006032000 은평구 0.016 0.053 0.3 0.003 41.0 19.0
22 202006032000 종로구 0.024 0.029 0.5 0.003 56.0 26.0
23 202006032000 중구 0.025 0.033 0.5 0.003 43.0 25.0
24 202006032000 중랑구 0.026 0.044 0.5 0.003 67.0 28.0
%% Cell type:code id: tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment