hossam 0.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
hossam-0.4.2/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Lee Kwang-Ho
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
+ SOFTWARE.
@@ -0,0 +1,5 @@
1
+ include README.md
2
+ include LICENSE
3
+ global-exclude __pycache__
4
+ recursive-include hossam *.ttf
5
+ recursive-include hossam *.png
hossam-0.4.2/PKG-INFO ADDED
@@ -0,0 +1,105 @@
1
+ Metadata-Version: 2.4
2
+ Name: hossam
3
+ Version: 0.4.2
4
+ Summary: Hossam Data Helper
5
+ Author-email: Lee Kwang-Ho <leekh4232@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/leekh4232/hossam-py
8
+ Project-URL: Repository, https://github.com/leekh4232/hossam-py
9
+ Keywords: data,analysis,helper,hossam,tensorflow
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Topic :: Software Development :: Libraries
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Requires-Python: >=3.11
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: tqdm
19
+ Requires-Dist: tabulate
20
+ Requires-Dist: pandas
21
+ Requires-Dist: matplotlib
22
+ Requires-Dist: seaborn
23
+ Requires-Dist: requests
24
+ Requires-Dist: openpyxl
25
+ Requires-Dist: xlrd
26
+ Requires-Dist: statsmodels
27
+ Requires-Dist: scipy
28
+ Requires-Dist: scikit-learn
29
+ Requires-Dist: pingouin
30
+ Requires-Dist: statannotations
31
+ Requires-Dist: joblib
32
+ Requires-Dist: geopandas
33
+ Requires-Dist: kmodes
34
+ Requires-Dist: pmdarima
35
+ Requires-Dist: prophet
36
+ Requires-Dist: plotly
37
+ Requires-Dist: jenkspy
38
+ Requires-Dist: flask
39
+ Requires-Dist: xgboost
40
+ Requires-Dist: lightgbm
41
+ Requires-Dist: catboost
42
+ Dynamic: license-file
43
+
44
+ ---
45
+ title: πŸŽ“ Hossam Data Helper
46
+ ---
47
+
48
+ # πŸŽ“ Hossam Data Helper
49
+
50
+ [![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
51
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
52
+ [![Version](https://img.shields.io/badge/version-0.3.19-green.svg)](https://pypi.org/project/hossam/)
53
+ [![Documentation](https://img.shields.io/badge/docs-py.hossam.kr-blue.svg)](https://py.hossam.kr)
54
+
55
+ **Hossam**은 데이터 뢄석, μ‹œκ°ν™”, 톡계 처리λ₯Ό μœ„ν•œ μ’…ν•© 헬퍼 λΌμ΄λΈŒλŸ¬λ¦¬μž…λ‹ˆλ‹€.
56
+
57
+ μ•„μ΄ν‹°μœŒ(ITWILL)μ—μ„œ μ§„ν–‰ 쀑인 λ¨Έμ‹ λŸ¬λ‹ 및 데이터 뢄석 μˆ˜μ—…μ„ μœ„ν•΄ κ°œλ°œλ˜μ—ˆμœΌλ©°, μ΄κ΄‘ν˜Έ κ°•μ‚¬μ˜ κ°•μ˜μ—μ„œ ν™œμš©λ©λ‹ˆλ‹€.
58
+
59
+ ## ✨ μ£Όμš” νŠΉμ§•
60
+
61
+ - πŸ“Š **ν’λΆ€ν•œ μ‹œκ°ν™”**: 25+ μ‹œκ°ν™” ν•¨μˆ˜ (Seaborn/Matplotlib 기반)
62
+ - 🎯 **톡계 뢄석**: νšŒκ·€, λΆ„λ₯˜, μ‹œκ³„μ—΄ 뢄석 도ꡬ
63
+ - πŸ“¦ **μƒ˜ν”Œ 데이터**: ν•™μŠ΅μš© 데이터셋 μ¦‰μ‹œ λ‘œλ“œ
64
+ - πŸ”§ **데이터 μ „μ²˜λ¦¬**: 결츑치 처리, μ΄μƒμΉ˜ 탐지, μŠ€μΌ€μΌλ§
65
+ - πŸ€– **MCP μ„œλ²„**: VSCode/Copilotκ³Ό 톡합 κ°€λŠ₯ν•œ Model Context Protocol 지원
66
+ - πŸ“ˆ **ꡐ윑용 μ΅œμ ν™”**: 데이터 뢄석 κ΅μœ‘μ— νŠΉν™”λœ 섀계
67
+
68
+
69
+ ## πŸ“¦ μ„€μΉ˜
70
+
71
+ ```bash
72
+ pip install hossam
73
+ ```
74
+
75
+ **μš”κ΅¬μ‚¬ν•­**: Python 3.8 이상
76
+
77
+ ## πŸ“š 전체 λ¬Έμ„œ
78
+
79
+ **μ™„μ „ν•œ API λ¬Έμ„œμ™€ κ°€μ΄λ“œλŠ” [py.hossam.kr](https://py.hossam.kr)μ—μ„œ ν™•μΈν•˜μ„Έμš”.**
80
+
81
+ ### μ£Όμš” λͺ¨λ“ˆ
82
+
83
+ - **hs_plot**: 25+ μ‹œκ°ν™” ν•¨μˆ˜ (μ„  κ·Έλž˜ν”„, 산점도, νžˆμŠ€ν† κ·Έλž¨, λ°•μŠ€ν”Œλ‘―, 히트맡 λ“±)
84
+ - **hs_stats**: νšŒκ·€/λΆ„λ₯˜ 뢄석, ꡐ차검증, μ •κ·œμ„± κ²€μ •, 상관뢄석 λ“±
85
+ - **hs_prep**: 결츑치 처리, μ΄μƒμΉ˜ 탐지, μŠ€μΌ€μΌλ§, 인코딩
86
+ - **hs_gis**: GIS 데이터 λ‘œλ“œ 및 μ‹œκ°ν™” (λŒ€ν•œλ―Όκ΅­ 지도 지원)
87
+ - **hs_classroom**: ν•™μŠ΅μš© 이진뢄λ₯˜, 닀쀑뢄λ₯˜, νšŒκ·€ 데이터 생성
88
+ - **hs_util**: 예쁜 ν…Œμ΄λΈ” 좜λ ₯, κ·Έλ¦¬λ“œ μ„œμΉ˜ λ“±
89
+
90
+ μžμ„Έν•œ μ‚¬μš©λ²•μ€ [API λ¬Έμ„œ](https://py.hossam.kr/api/hossam/)λ₯Ό μ°Έκ³ ν•˜μ„Έμš”.
91
+
92
+
93
+ ## πŸ“„ λΌμ΄μ„ μŠ€
94
+
95
+ 이 ν”„λ‘œμ νŠΈλŠ” MIT λΌμ΄μ„ μŠ€λ₯Ό λ”°λ¦…λ‹ˆλ‹€. 자유둭게 μ‚¬μš©, μˆ˜μ •, 배포할 수 μžˆμŠ΅λ‹ˆλ‹€.
96
+
97
+ ## πŸ”— 링크
98
+
99
+ - **λ¬Έμ„œ**: [py.hossam.kr](https://py.hossam.kr)
100
+ - **PyPI**: [pypi.org/project/hossam](https://pypi.org/project/hossam/)
101
+ - **강사**: μ΄κ΄‘ν˜Έ (ITWILL λ¨Έμ‹ λŸ¬λ‹ 및 데이터 뢄석)
102
+
103
+ ---
104
+
105
+ {% include 'HOSSAM_API.md' %}
hossam-0.4.2/README.md ADDED
@@ -0,0 +1,62 @@
1
+ ---
2
+ title: πŸŽ“ Hossam Data Helper
3
+ ---
4
+
5
+ # πŸŽ“ Hossam Data Helper
6
+
7
+ [![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
+ [![Version](https://img.shields.io/badge/version-0.3.19-green.svg)](https://pypi.org/project/hossam/)
10
+ [![Documentation](https://img.shields.io/badge/docs-py.hossam.kr-blue.svg)](https://py.hossam.kr)
11
+
12
+ **Hossam**은 데이터 뢄석, μ‹œκ°ν™”, 톡계 처리λ₯Ό μœ„ν•œ μ’…ν•© 헬퍼 λΌμ΄λΈŒλŸ¬λ¦¬μž…λ‹ˆλ‹€.
13
+
14
+ μ•„μ΄ν‹°μœŒ(ITWILL)μ—μ„œ μ§„ν–‰ 쀑인 λ¨Έμ‹ λŸ¬λ‹ 및 데이터 뢄석 μˆ˜μ—…μ„ μœ„ν•΄ κ°œλ°œλ˜μ—ˆμœΌλ©°, μ΄κ΄‘ν˜Έ κ°•μ‚¬μ˜ κ°•μ˜μ—μ„œ ν™œμš©λ©λ‹ˆλ‹€.
15
+
16
+ ## ✨ μ£Όμš” νŠΉμ§•
17
+
18
+ - πŸ“Š **ν’λΆ€ν•œ μ‹œκ°ν™”**: 25+ μ‹œκ°ν™” ν•¨μˆ˜ (Seaborn/Matplotlib 기반)
19
+ - 🎯 **톡계 뢄석**: νšŒκ·€, λΆ„λ₯˜, μ‹œκ³„μ—΄ 뢄석 도ꡬ
20
+ - πŸ“¦ **μƒ˜ν”Œ 데이터**: ν•™μŠ΅μš© 데이터셋 μ¦‰μ‹œ λ‘œλ“œ
21
+ - πŸ”§ **데이터 μ „μ²˜λ¦¬**: 결츑치 처리, μ΄μƒμΉ˜ 탐지, μŠ€μΌ€μΌλ§
22
+ - πŸ€– **MCP μ„œλ²„**: VSCode/Copilotκ³Ό 톡합 κ°€λŠ₯ν•œ Model Context Protocol 지원
23
+ - πŸ“ˆ **ꡐ윑용 μ΅œμ ν™”**: 데이터 뢄석 κ΅μœ‘μ— νŠΉν™”λœ 섀계
24
+
25
+
26
+ ## πŸ“¦ μ„€μΉ˜
27
+
28
+ ```bash
29
+ pip install hossam
30
+ ```
31
+
32
+ **μš”κ΅¬μ‚¬ν•­**: Python 3.8 이상
33
+
34
+ ## πŸ“š 전체 λ¬Έμ„œ
35
+
36
+ **μ™„μ „ν•œ API λ¬Έμ„œμ™€ κ°€μ΄λ“œλŠ” [py.hossam.kr](https://py.hossam.kr)μ—μ„œ ν™•μΈν•˜μ„Έμš”.**
37
+
38
+ ### μ£Όμš” λͺ¨λ“ˆ
39
+
40
+ - **hs_plot**: 25+ μ‹œκ°ν™” ν•¨μˆ˜ (μ„  κ·Έλž˜ν”„, 산점도, νžˆμŠ€ν† κ·Έλž¨, λ°•μŠ€ν”Œλ‘―, 히트맡 λ“±)
41
+ - **hs_stats**: νšŒκ·€/λΆ„λ₯˜ 뢄석, ꡐ차검증, μ •κ·œμ„± κ²€μ •, 상관뢄석 λ“±
42
+ - **hs_prep**: 결츑치 처리, μ΄μƒμΉ˜ 탐지, μŠ€μΌ€μΌλ§, 인코딩
43
+ - **hs_gis**: GIS 데이터 λ‘œλ“œ 및 μ‹œκ°ν™” (λŒ€ν•œλ―Όκ΅­ 지도 지원)
44
+ - **hs_classroom**: ν•™μŠ΅μš© 이진뢄λ₯˜, 닀쀑뢄λ₯˜, νšŒκ·€ 데이터 생성
45
+ - **hs_util**: 예쁜 ν…Œμ΄λΈ” 좜λ ₯, κ·Έλ¦¬λ“œ μ„œμΉ˜ λ“±
46
+
47
+ μžμ„Έν•œ μ‚¬μš©λ²•μ€ [API λ¬Έμ„œ](https://py.hossam.kr/api/hossam/)λ₯Ό μ°Έκ³ ν•˜μ„Έμš”.
48
+
49
+
50
+ ## πŸ“„ λΌμ΄μ„ μŠ€
51
+
52
+ 이 ν”„λ‘œμ νŠΈλŠ” MIT λΌμ΄μ„ μŠ€λ₯Ό λ”°λ¦…λ‹ˆλ‹€. 자유둭게 μ‚¬μš©, μˆ˜μ •, 배포할 수 μžˆμŠ΅λ‹ˆλ‹€.
53
+
54
+ ## πŸ”— 링크
55
+
56
+ - **λ¬Έμ„œ**: [py.hossam.kr](https://py.hossam.kr)
57
+ - **PyPI**: [pypi.org/project/hossam](https://pypi.org/project/hossam/)
58
+ - **강사**: μ΄κ΄‘ν˜Έ (ITWILL λ¨Έμ‹ λŸ¬λ‹ 및 데이터 뢄석)
59
+
60
+ ---
61
+
62
+ {% include 'HOSSAM_API.md' %}
@@ -0,0 +1,84 @@
1
+ # submodules
2
+ from . import hs_classroom
3
+ from . import hs_gis
4
+ from . import hs_plot
5
+ from . import hs_prep
6
+ from . import hs_stats
7
+ from . import hs_timeserise
8
+ from . import hs_util
9
+ from .data_loader import load_data, load_info
10
+
11
+ # py-modules
12
+ import sys
13
+ import warnings
14
+ from matplotlib import pyplot as plt
15
+ from matplotlib import font_manager as fm
16
+ from importlib.resources import files, as_file
17
+ from importlib.metadata import version
18
+
19
+ try:
20
+ __version__ = version("hossam")
21
+ except Exception:
22
+ __version__ = "develop"
23
+
24
+ __all__ = ["load_data", "load_info", "hs_classroom", "hs_gis", "hs_plot", "hs_prep", "hs_stats", "hs_timeserise", "hs_util"]
25
+
26
+ # λ‚΄λΆ€ λͺ¨λ“ˆμ—μ„œ hs_figλ₯Ό μ‚¬μš©ν•  λ•ŒλŠ” μ•„λž˜μ™€ 같이 import ν•˜μ„Έμš”.
27
+ # from hossam import hs_fig
28
+
29
+
30
+ def _init_korean_font():
31
+ """
32
+ νŒ¨ν‚€μ§€μ— ν¬ν•¨λœ ν•œκΈ€ 폰트λ₯Ό κΈ°λ³Έ 폰트둜 μ„€μ •ν•©λ‹ˆλ‹€.
33
+ """
34
+ font_file = "NotoSansKR-Regular.ttf"
35
+ try:
36
+ # νŒ¨ν‚€μ§€ λ¦¬μ†ŒμŠ€μ—μ„œ 폰트 파일 경둜 확보
37
+ with as_file(files("hossam") / font_file) as font_path:
38
+ fm.fontManager.addfont(str(font_path))
39
+ fprop = fm.FontProperties(fname=str(font_path))
40
+ fname = fprop.get_name()
41
+
42
+ plt.rcParams.update({
43
+ "font.family": fname,
44
+ "font.size": hs_plot.config.font_size,
45
+ "font.weight": hs_plot.config.font_weight,
46
+ "axes.unicode_minus": False,
47
+ "text.antialiased": True,
48
+ "lines.antialiased": True,
49
+ "patch.antialiased": True,
50
+ "figure.dpi": hs_plot.config.dpi,
51
+ "savefig.dpi": hs_plot.config.dpi * 2,
52
+ "text.hinting": "auto",
53
+ "text.hinting_factor": 8,
54
+ "pdf.fonttype": 42,
55
+ "ps.fonttype": 42,
56
+ })
57
+ if sys.stdout.isatty():
58
+ print(
59
+ "\nβœ… μ‹œκ°ν™”λ₯Ό μœ„ν•œ ν•œκΈ€ κΈ€κΌ΄(NotoSansKR-Regular)이 μžλ™ μ μš©λ˜μ—ˆμŠ΅λ‹ˆλ‹€."
60
+ )
61
+ return
62
+ except Exception as e:
63
+ warnings.warn(f"\nν•œκΈ€ 폰트 μ΄ˆκΈ°ν™”: νŒ¨ν‚€μ§€ 폰트 μ‚¬μš© μ‹€νŒ¨ ({e}).")
64
+
65
+
66
+ def _init():
67
+
68
+ # μ•ˆλ‚΄ λ©”μ‹œμ§€ (λΈ”λ¦Ώ 리슀트)
69
+ messages = [
70
+ "πŸ“¦ μ•„μ΄ν‹°μœŒ μ΄κ΄‘ν˜Έ 강사가 μ œμž‘ν•œ 라이브러리λ₯Ό μ‚¬μš©μ€‘μž…λ‹ˆλ‹€.",
71
+ "πŸ“š μžμ„Έν•œ μ‚¬μš© 방법은 https://py.hossam.kr 을 μ°Έκ³ ν•˜μ„Έμš”.",
72
+ "πŸ“§ Email: leekh4232@gmail.com",
73
+ "🎬 Youtube: https://www.youtube.com/@hossam-codingclub",
74
+ "πŸ“ Blog: https://blog.hossam.kr/",
75
+ f"πŸ”– Version: {__version__}",
76
+ ]
77
+
78
+ for msg in messages:
79
+ print(f"{msg}")
80
+
81
+ _init_korean_font()
82
+
83
+
84
+ _init()
@@ -0,0 +1,205 @@
1
+ # -*- coding: utf-8 -*-
2
+ # -------------------------------------------------------------
3
+
4
+ import requests
5
+ import json
6
+ from os.path import join, exists
7
+ from io import BytesIO
8
+ from pandas import DataFrame, read_csv, read_excel
9
+ from typing import Optional
10
+ from typing import Optional
11
+
12
+ BASE_URL = "https://data.hossam.kr"
13
+
14
+ # -------------------------------------------------------------
15
+ def __get_df(path: str, index_col=None) -> DataFrame:
16
+ p = path.rfind(".")
17
+ exec = path[p+1:].lower()
18
+
19
+ if exec == 'xlsx':
20
+ # If path is a remote URL, fetch the file once and reuse the bytes
21
+ if path.lower().startswith(('http://', 'https://')):
22
+ path = path.replace("\\", "/")
23
+ with requests.Session() as session:
24
+ r = session.get(path)
25
+
26
+ if r.status_code != 200:
27
+ raise Exception(f"HTTP {r.status_code} Error - {r.reason} > {path}")
28
+
29
+ data_bytes = r.content
30
+
31
+ # Use separate BytesIO objects for each read to avoid pointer/stream issues
32
+ df = read_excel(BytesIO(data_bytes), index_col=index_col)
33
+
34
+ try:
35
+ info = read_excel(BytesIO(data_bytes), sheet_name='metadata', index_col=0)
36
+ #print("\033[94m[metadata]\033[0m")
37
+ print()
38
+ from .util import hs_pretty_table
39
+ hs_pretty_table(info)
40
+ print()
41
+ except Exception:
42
+ #print(f"\033[91m[!] Cannot read metadata\033[0m")
43
+ pass
44
+ else:
45
+ df = read_excel(path, index_col=index_col)
46
+
47
+ try:
48
+ info = read_excel(path, sheet_name='metadata', index_col=0)
49
+ #print("\033[94m[metadata]\033[0m")
50
+ print()
51
+ from .util import hs_pretty_table
52
+ hs_pretty_table(info)
53
+ print()
54
+ except:
55
+ #print(f"\033[91m[!] Cannot read metadata\033[0m")
56
+ pass
57
+ else:
58
+ df = read_csv(path, index_col=index_col)
59
+
60
+ return df
61
+
62
+ # -------------------------------------------------------------
63
+ def __get_data_url(key: str, local: str = None) -> str:
64
+ global BASE_URL
65
+
66
+ path = None
67
+
68
+ if not local:
69
+ data_path = join(BASE_URL, "metadata.json").replace("\\", "/")
70
+
71
+ with requests.Session() as session:
72
+ r = session.get(data_path)
73
+
74
+ if r.status_code != 200:
75
+ raise Exception("[%d Error] %s" % (r.status_code, r.reason))
76
+
77
+ my_dict = r.json()
78
+ info = my_dict.get(key.lower())
79
+
80
+ if not info:
81
+ raise FileNotFoundError("%sλŠ” μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” 데이터에 λŒ€ν•œ μš”μ²­μž…λ‹ˆλ‹€." % key)
82
+
83
+ path = join(BASE_URL, info['url'])
84
+ else:
85
+ data_path = join(local, "metadata.json")
86
+
87
+ if not exists(data_path):
88
+ raise FileNotFoundError("μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” 데이터에 λŒ€ν•œ μš”μ²­μž…λ‹ˆλ‹€.")
89
+
90
+ with open(data_path, "r", encoding="utf-8") as f:
91
+ my_dict = json.loads(f.read())
92
+
93
+ info = my_dict.get(key.lower())
94
+ path = join(local, info['url'])
95
+
96
+ return path, info.get('desc'), info.get('index')
97
+
98
+ # -------------------------------------------------------------
99
+ def load_info(search: str = None, local: str = None) -> DataFrame:
100
+ """λ©”νƒ€λ°μ΄ν„°μ—μ„œ μ‚¬μš© κ°€λŠ₯ν•œ 데이터셋 정보λ₯Ό λ‘œλ“œν•œλ‹€.
101
+
102
+ Args:
103
+ search (str, optional): 이름 ν•„ν„° λ¬Έμžμ—΄. ν¬ν•¨ν•˜λŠ” ν•­λͺ©λ§Œ λ°˜ν™˜.
104
+ local (str, optional): 둜컬 메타데이터 경둜. None이면 원격(BASE_URL) μ‚¬μš©.
105
+
106
+ Returns:
107
+ DataFrame: name, chapter, desc, url μ»¬λŸΌμ„ κ°–λŠ” ν…Œμ΄λΈ”
108
+
109
+ Examples:
110
+ ```python
111
+ from hossam import *
112
+ info = load_info()
113
+ list(info.columns) #['name', 'chapter', 'desc', 'url']
114
+ ```
115
+ """
116
+ global BASE_URL
117
+
118
+ path = None
119
+
120
+ if not local:
121
+ data_path = join(BASE_URL, "metadata.json").replace("\\", "/")
122
+
123
+ with requests.Session() as session:
124
+ r = session.get(data_path)
125
+
126
+ if r.status_code != 200:
127
+ raise Exception("[%d Error] %s ::: %s" % (r.status_code, r.reason, data_path))
128
+
129
+ my_dict = r.json()
130
+ else:
131
+ data_path = join(local, "metadata.json")
132
+
133
+ if not exists(data_path):
134
+ raise FileNotFoundError("μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” 데이터에 λŒ€ν•œ μš”μ²­μž…λ‹ˆλ‹€.")
135
+
136
+ with open(data_path, "r", encoding="utf-8") as f:
137
+ my_dict = json.loads(f.read())
138
+
139
+ my_data = []
140
+ for key in my_dict:
141
+ if 'index' in my_dict[key]:
142
+ del my_dict[key]['index']
143
+
144
+ my_dict[key]['url'] = "%s/%s" % (BASE_URL, my_dict[key]['url'])
145
+ my_dict[key]['name'] = key
146
+
147
+ if 'chapter' in my_dict[key]:
148
+ my_dict[key]['chapter'] = ", ".join(my_dict[key]['chapter'])
149
+ else:
150
+ my_dict[key]['chapter'] = '곡톡'
151
+
152
+ my_data.append(my_dict[key])
153
+
154
+ my_df = DataFrame(my_data)
155
+ my_df2 = my_df.reindex(columns=['name', 'chapter', 'desc', 'url'])
156
+
157
+ if search:
158
+ my_df2 = my_df2[my_df2['name'].str.contains(search.lower())]
159
+
160
+ return my_df2
161
+
162
+ # -------------------------------------------------------------
163
+ def load_data(key: str, local: str = None) -> Optional[DataFrame]:
164
+ """ν‚€λ‘œ μ§€μ •λœ 데이터셋을 λ‘œλ“œν•œλ‹€.
165
+
166
+ Args:
167
+ key (str): 메타데이터에 μ •μ˜λœ 데이터 μ‹λ³„μž(파일λͺ… λ˜λŠ” 별칭)
168
+ local (str, optional): 둜컬 메타데이터 경둜. None이면 원격(BASE_URL) μ‚¬μš©.
169
+
170
+ Returns:
171
+ DataFrame | None: 성곡 μ‹œ λ°μ΄ν„°ν”„λ ˆμž„, μ‹€νŒ¨ μ‹œ None
172
+
173
+ Examples:
174
+ ```python
175
+ from hossam import *
176
+ df = load_data('AD_SALES') # 메타데이터에 ν•΄λ‹Ή ν‚€κ°€ μžˆμ–΄μ•Ό 함
177
+ ```
178
+ """
179
+ index = None
180
+ try:
181
+ url, desc, index = __get_data_url(key, local=local)
182
+ except Exception as e:
183
+ try:
184
+ print(f"\033[91m{str(e)}\033[0m")
185
+ except Exception:
186
+ print(e)
187
+ return
188
+
189
+ #print("\033[94m[data]\033[0m", url.replace("\\", "/"))
190
+ #print("\033[94m[desc]\033[0m", desc)
191
+ print(f"\033[94m{desc}\033[0m")
192
+
193
+ df = None
194
+
195
+ try:
196
+ df = __get_df(url, index_col=index)
197
+ except Exception as e:
198
+ try:
199
+ print(f"\033[91m{str(e)}\033[0m")
200
+ except Exception:
201
+ print(e)
202
+ return
203
+
204
+
205
+ return df