Skip to content

Commit

Permalink
Merge pull request #51 from WooilJeong/develop
Browse files Browse the repository at this point in the history
업데이트
  • Loading branch information
WooilJeong authored May 3, 2023
2 parents 4414796 + c7af7ec commit 0d0c19b
Show file tree
Hide file tree
Showing 17 changed files with 3,640 additions and 1,120 deletions.
1,146 changes: 1,035 additions & 111 deletions PublicDataReader/PublicDataPortal/kamco.py

Large diffs are not rendered by default.

868 changes: 1 addition & 867 deletions PublicDataReader/PublicDataPortal/molit.py

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions PublicDataReader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@
"__contact__",
"__github__",
"TransactionPrice",
"Transaction",
"BuildingLedger",
"BuildingLicense",
"HousingLicense",
"LandForestLedger",
"LandOwnership",
"Building",
"SmallShop",
"StoreInfo",
"Reb",
"Transportation",
"Kosis",
"_Kosis",
"VworldData",
"Kamco",
"Nts",
Expand Down
2 changes: 1 addition & 1 deletion PublicDataReader/config/info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.0.20"
__version__ = "1.0.21"
__author__ = "정우일(Wooil Jeong)"
__contact__ = "[email protected]"
__github__ = "https://github.com/WooilJeong/PublicDataReader"
4 changes: 0 additions & 4 deletions PublicDataReader/data.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# 국토교통부(molit) Open API 통합
from PublicDataReader.PublicDataPortal.molit import TransactionPrice, BuildingLedger, BuildingLicense, HousingLicense, LandForestLedger, LandOwnership
# (Deprecated)
from PublicDataReader.PublicDataPortal.molit import Transaction, Building

# 소상공인 진흥공단(semas) Open API 통합
from PublicDataReader.PublicDataPortal.semas import SmallShop
# (Deprecated)
from PublicDataReader.PublicDataPortal.semas import StoreInfo

# 한국부동산원(REB) Open API 통합
from PublicDataReader.PublicDataPortal.reb import Reb
Expand Down
102 changes: 0 additions & 102 deletions PublicDataReader/kosis/kosis.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,105 +353,3 @@ def translate_columns(self, df, service_name, detail_service_name=None):
"서비스명을 확인해주세요. (ex. KOSIS통합검색, 통계설명, 통계표설명, 통계목록, 통계자료)")

return df.rename(columns=rename_columns)


class _Kosis:
"""(삭제 예정) KOSIS 공유서비스 클래스
KOSIS 공유서비스에서 발급받은 사용자 인증키를 입력받아 초기화합니다.
Parameters
----------
apiKey : str
KOSIS 공유서비스에서 발급받은 사용자 인증키
serviceName : str
KOSIS 공유서비스 서비스명
Examples
--------
>>> import PublicDataReader as pdr
>>> # KOSIS 공유서비스 OPEN API 인스턴스 생성
>>> apiKey = "YOUR_API_KEY"
>>> serviceName = "KOSIS통합검색" # (예시) KOSIS통합검색, 통계설명, 통계표설명, 통계목록, 통계자료
>>> kosis = pdr.Kosis(apiKey, serviceName)
"""

def __init__(self, apiKey, serviceName):
self.apiKey = apiKey
url_dict = {
"KOSIS통합검색": "https://kosis.kr/openapi/statisticsSearch.do?method=getList",
"통계설명": "https://kosis.kr/openapi/statisticsExplData.do?method=getList",
"통계표설명": "https://kosis.kr/openapi/statisticsData.do?method=getMeta",
"통계목록": "https://kosis.kr/openapi/statisticsList.do?method=getList",
"통계자료": "https://kosis.kr/openapi/Param/statisticsParameterData.do?method=getList",
}
self.url = url_dict.get(serviceName)

def get_data(self, **kwargs):
"""API 호출
KOSIS 공유서비스 API를 호출하여 데이터를 반환합니다.
Parameters
----------
**kwargs : dict
API 호출에 필요한 파라미터
Returns
-------
DataFrame
API 호출 결과를 DataFrame 형태로 반환합니다.
Examples
--------
>>> import PublicDataReader as pdr
>>> # KOSIS 공유서비스 OPEN API 인스턴스 생성
>>> apiKey = "YOUR_API_KEY"
>>> serviceName = "KOSIS통합검색"
>>> kosis = pdr.Kosis(apiKey, serviceName)
>>> # 파라미터 설정
>>> orgId = "101"
>>> tblId = "DT_1B040A3"
>>> metaItm = "ALL"
>>> # 데이터 조회
>>> df = kosis.get_data(orgId=orgId, tblId=tblId, metaItm=metaItm)
"""
try:
kwargs["apiKey"] = self.apiKey
kwargs["format"] = "json"
kwargs["jsonVD"] = "Y"
kwargs["jsonMVD"] = "Y"
if kwargs.get("detailServiceName"):
type_dict = {
"통계표명칭": "TBL",
"기관명칭": "ORG",
"수록정보": "PRD",
"분류항목": "ITM",
"주석": "CMMT",
"단위": "UNIT",
"출처": "SOURCE",
"가중치": "WGT",
"자료갱신일": "NCD",
}
kwargs['type'] = type_dict.get(kwargs.get("detailServiceName"))
kwargs.pop("detailServiceName")
except:
print("Incorrect Value!")
return None

try:
res = requests.get(self.url, params=kwargs, verify=False).json()
except:
print("Request Failed!")
return None

try:
if type(res) == dict:
if res.get("errMsg"):
print(res.get("errMsg"))
return None
else:
return pd.DataFrame(res)
except:
print("Data Frame Failed!")
return None
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion PublicDataReader/raw/code_hdong.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion PublicDataReader/raw/code_hdong_bdong.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions PublicDataReader/utils/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@


CODE_INFORMATION = F"""\
출처: 행정기관(행정동) 및 관할구역(법정동) 변경내역(2023. 2. 24. 시행)
URL: https://www.mois.go.kr/frt/bbs/type001/commonSelectBoardArticle.do?bbsId=BBSMSTR_000000000052&nttId=98870
출처: 행정기관(행정동) 및 관할구역(법정동) 변경내역(2023. 5. 1. 시행)
URL: https://www.mois.go.kr/frt/bbs/type001/commonSelectBoardArticle.do?bbsId=BBSMSTR_000000000052&nttId=100215
"""


Expand Down
Loading

0 comments on commit 0d0c19b

Please sign in to comment.