Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
WooilJeong committed Oct 21, 2022
1 parent 9264e53 commit 9d44d1c
Show file tree
Hide file tree
Showing 28 changed files with 1,956 additions and 38 deletions.
4 changes: 2 additions & 2 deletions PublicDataReader/config/info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.0.1"
__version__ = "1.0.2"
__author__ = "정우일(Wooil Jeong)"
__contact__ = "[email protected]"
__github__ = "https://github.com/WooilJeong/PublicDataReader"
__github__ = "https://github.com/WooilJeong/PublicDataReader"
46 changes: 45 additions & 1 deletion PublicDataReader/kosis/kosis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,25 @@


class Kosis:
"""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
Expand All @@ -22,6 +40,32 @@ def __init__(self, apiKey, 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
Expand Down
1 change: 1 addition & 0 deletions docs/PublicDataReader.PublicDataPortal.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<li class="toctree-l4 current"><a class="current reference internal" href="#">PublicDataReader.PublicDataPortal package</a></li>
<li class="toctree-l4"><a class="reference internal" href="PublicDataReader.Seoul.html">PublicDataReader.Seoul package</a></li>
<li class="toctree-l4"><a class="reference internal" href="PublicDataReader.config.html">PublicDataReader.config package</a></li>
<li class="toctree-l4"><a class="reference internal" href="PublicDataReader.kosis.html">PublicDataReader.kosis package</a></li>
<li class="toctree-l4"><a class="reference internal" href="PublicDataReader.utils.html">PublicDataReader.utils package</a></li>
</ul>
</li>
Expand Down
1 change: 1 addition & 0 deletions docs/PublicDataReader.Seoul.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<li class="toctree-l4"><a class="reference internal" href="PublicDataReader.PublicDataPortal.html">PublicDataReader.PublicDataPortal package</a></li>
<li class="toctree-l4 current"><a class="current reference internal" href="#">PublicDataReader.Seoul package</a></li>
<li class="toctree-l4"><a class="reference internal" href="PublicDataReader.config.html">PublicDataReader.config package</a></li>
<li class="toctree-l4"><a class="reference internal" href="PublicDataReader.kosis.html">PublicDataReader.kosis package</a></li>
<li class="toctree-l4"><a class="reference internal" href="PublicDataReader.utils.html">PublicDataReader.utils package</a></li>
</ul>
</li>
Expand Down
5 changes: 3 additions & 2 deletions docs/PublicDataReader.config.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<script src="_static/js/theme.js"></script>
<link rel="index" title="색인" href="genindex.html" />
<link rel="search" title="검색" href="search.html" />
<link rel="next" title="PublicDataReader.utils package" href="PublicDataReader.utils.html" />
<link rel="next" title="PublicDataReader.kosis package" href="PublicDataReader.kosis.html" />
<link rel="prev" title="PublicDataReader.Seoul package" href="PublicDataReader.Seoul.html" />
</head>

Expand All @@ -46,6 +46,7 @@
<li class="toctree-l4"><a class="reference internal" href="PublicDataReader.PublicDataPortal.html">PublicDataReader.PublicDataPortal package</a></li>
<li class="toctree-l4"><a class="reference internal" href="PublicDataReader.Seoul.html">PublicDataReader.Seoul package</a></li>
<li class="toctree-l4 current"><a class="current reference internal" href="#">PublicDataReader.config package</a></li>
<li class="toctree-l4"><a class="reference internal" href="PublicDataReader.kosis.html">PublicDataReader.kosis package</a></li>
<li class="toctree-l4"><a class="reference internal" href="PublicDataReader.utils.html">PublicDataReader.utils package</a></li>
</ul>
</li>
Expand Down Expand Up @@ -102,7 +103,7 @@ <h2>Submodules<a class="headerlink" href="#submodules" title="이 표제에 대
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="PublicDataReader.Seoul.html" class="btn btn-neutral float-left" title="PublicDataReader.Seoul package" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="PublicDataReader.utils.html" class="btn btn-neutral float-right" title="PublicDataReader.utils package" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
<a href="PublicDataReader.kosis.html" class="btn btn-neutral float-right" title="PublicDataReader.kosis package" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>

<hr/>
Expand Down
63 changes: 63 additions & 0 deletions docs/PublicDataReader.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<li class="toctree-l4"><a class="reference internal" href="PublicDataReader.PublicDataPortal.html">PublicDataReader.PublicDataPortal package</a></li>
<li class="toctree-l4"><a class="reference internal" href="PublicDataReader.Seoul.html">PublicDataReader.Seoul package</a></li>
<li class="toctree-l4"><a class="reference internal" href="PublicDataReader.config.html">PublicDataReader.config package</a></li>
<li class="toctree-l4"><a class="reference internal" href="PublicDataReader.kosis.html">PublicDataReader.kosis package</a></li>
<li class="toctree-l4"><a class="reference internal" href="PublicDataReader.utils.html">PublicDataReader.utils package</a></li>
</ul>
</li>
Expand Down Expand Up @@ -108,6 +109,12 @@ <h2>Subpackages<a class="headerlink" href="#subpackages" title="이 표제에
<li class="toctree-l2"><a class="reference internal" href="PublicDataReader.config.html#module-PublicDataReader.config">Module contents</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="PublicDataReader.kosis.html">PublicDataReader.kosis package</a><ul>
<li class="toctree-l2"><a class="reference internal" href="PublicDataReader.kosis.html#submodules">Submodules</a></li>
<li class="toctree-l2"><a class="reference internal" href="PublicDataReader.kosis.html#module-PublicDataReader.kosis.kosis">PublicDataReader.kosis.kosis module</a></li>
<li class="toctree-l2"><a class="reference internal" href="PublicDataReader.kosis.html#module-PublicDataReader.kosis">Module contents</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="PublicDataReader.utils.html">PublicDataReader.utils package</a><ul>
<li class="toctree-l2"><a class="reference internal" href="PublicDataReader.utils.html#submodules">Submodules</a></li>
<li class="toctree-l2"><a class="reference internal" href="PublicDataReader.utils.html#module-PublicDataReader.utils.code">PublicDataReader.utils.code module</a></li>
Expand Down Expand Up @@ -158,6 +165,62 @@ <h2>Submodules<a class="headerlink" href="#submodules" title="이 표제에 대

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="PublicDataReader.Kosis">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">PublicDataReader.</span></span><span class="sig-name descname"><span class="pre">Kosis</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">apiKey</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">serviceName</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PublicDataReader.Kosis" title="이 정의에 대한 퍼머링크"></a></dt>
<dd><p>기반 클래스: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>KOSIS 공유서비스 클래스</p>
<p>KOSIS 공유서비스에서 발급받은 사용자 인증키를 입력받아 초기화합니다.</p>
<dl class="field-list simple">
<dt class="field-odd">매개변수</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>apiKey</strong> (<em>str</em>) – KOSIS 공유서비스에서 발급받은 사용자 인증키</p></li>
<li><p><strong>serviceName</strong> (<em>str</em>) – KOSIS 공유서비스 서비스명</p></li>
</ul>
</dd>
</dl>
<p class="rubric">예제</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">PublicDataReader</span> <span class="k">as</span> <span class="nn">pdr</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># KOSIS 공유서비스 OPEN API 인스턴스 생성</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">apiKey</span> <span class="o">=</span> <span class="s2">&quot;YOUR_API_KEY&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">serviceName</span> <span class="o">=</span> <span class="s2">&quot;KOSIS통합검색&quot;</span> <span class="c1"># (예시) KOSIS통합검색, 통계설명, 통계표설명, 통계목록, 통계자료</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">kosis</span> <span class="o">=</span> <span class="n">pdr</span><span class="o">.</span><span class="n">Kosis</span><span class="p">(</span><span class="n">apiKey</span><span class="p">,</span> <span class="n">serviceName</span><span class="p">)</span>
</pre></div>
</div>
<dl class="py method">
<dt class="sig sig-object py" id="PublicDataReader.Kosis.get_data">
<span class="sig-name descname"><span class="pre">get_data</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PublicDataReader.Kosis.get_data" title="이 정의에 대한 퍼머링크"></a></dt>
<dd><p>API 호출</p>
<p>KOSIS 공유서비스 API를 호출하여 데이터를 반환합니다.</p>
<dl class="field-list simple">
<dt class="field-odd">매개변수</dt>
<dd class="field-odd"><p><strong>**kwargs</strong> (<em>dict</em>) – API 호출에 필요한 파라미터</p>
</dd>
<dt class="field-even">반환</dt>
<dd class="field-even"><p>API 호출 결과를 DataFrame 형태로 반환합니다.</p>
</dd>
<dt class="field-odd">반환 형식</dt>
<dd class="field-odd"><p>DataFrame</p>
</dd>
</dl>
<p class="rubric">예제</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">PublicDataReader</span> <span class="k">as</span> <span class="nn">pdr</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># KOSIS 공유서비스 OPEN API 인스턴스 생성</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">apiKey</span> <span class="o">=</span> <span class="s2">&quot;YOUR_API_KEY&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">serviceName</span> <span class="o">=</span> <span class="s2">&quot;KOSIS통합검색&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">kosis</span> <span class="o">=</span> <span class="n">pdr</span><span class="o">.</span><span class="n">Kosis</span><span class="p">(</span><span class="n">apiKey</span><span class="p">,</span> <span class="n">serviceName</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># 파라미터 설정</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">orgId</span> <span class="o">=</span> <span class="s2">&quot;101&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">tblId</span> <span class="o">=</span> <span class="s2">&quot;DT_1B040A3&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">metaItm</span> <span class="o">=</span> <span class="s2">&quot;ALL&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># 데이터 조회</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">df</span> <span class="o">=</span> <span class="n">kosis</span><span class="o">.</span><span class="n">get_data</span><span class="p">(</span><span class="n">orgId</span><span class="o">=</span><span class="n">orgId</span><span class="p">,</span> <span class="n">tblId</span><span class="o">=</span><span class="n">tblId</span><span class="p">,</span> <span class="n">metaItm</span><span class="o">=</span><span class="n">metaItm</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="PublicDataReader.StoreInfo">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">PublicDataReader.</span></span><span class="sig-name descname"><span class="pre">StoreInfo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">serviceKey</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">debug</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PublicDataReader.StoreInfo" title="이 정의에 대한 퍼머링크"></a></dt>
Expand Down
Loading

0 comments on commit 9d44d1c

Please sign in to comment.