hossam 0.2.1__tar.gz → 0.3.19__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.3.19/MANIFEST.in +5 -0
- hossam-0.3.19/PKG-INFO +206 -0
- hossam-0.3.19/README.md +167 -0
- hossam-0.3.19/hossam/NotoSansKR-Regular.ttf +0 -0
- hossam-0.3.19/hossam/__init__.py +89 -0
- {hossam-0.2.1 → hossam-0.3.19}/hossam/data_loader.py +46 -17
- hossam-0.3.19/hossam/hs_classroom.py +733 -0
- hossam-0.3.19/hossam/hs_gis.py +301 -0
- hossam-0.3.19/hossam/hs_plot.py +2408 -0
- hossam-0.3.19/hossam/hs_prep.py +879 -0
- hossam-0.3.19/hossam/hs_stats.py +2992 -0
- hossam-0.3.19/hossam/hs_timeserise.py +1104 -0
- hossam-0.3.19/hossam/hs_util.py +210 -0
- hossam-0.3.19/hossam/leekh.png +0 -0
- hossam-0.3.19/hossam/mcp/__init__.py +12 -0
- hossam-0.3.19/hossam/mcp/hs_classroom.py +22 -0
- hossam-0.3.19/hossam/mcp/hs_gis.py +30 -0
- hossam-0.3.19/hossam/mcp/hs_plot.py +53 -0
- hossam-0.3.19/hossam/mcp/hs_prep.py +61 -0
- hossam-0.3.19/hossam/mcp/hs_stats.py +25 -0
- hossam-0.3.19/hossam/mcp/hs_timeserise.py +22 -0
- hossam-0.3.19/hossam/mcp/hs_util.py +30 -0
- hossam-0.3.19/hossam/mcp/loader.py +29 -0
- hossam-0.3.19/hossam/mcp/server.py +675 -0
- hossam-0.3.19/hossam.egg-info/PKG-INFO +206 -0
- hossam-0.3.19/hossam.egg-info/SOURCES.txt +31 -0
- hossam-0.3.19/hossam.egg-info/entry_points.txt +2 -0
- {hossam-0.2.1 → hossam-0.3.19}/hossam.egg-info/requires.txt +8 -0
- hossam-0.3.19/pyproject.toml +58 -0
- hossam-0.3.19/setup.cfg +4 -0
- hossam-0.2.1/MANIFEST.in +0 -3
- hossam-0.2.1/PKG-INFO +0 -75
- hossam-0.2.1/README.md +0 -33
- hossam-0.2.1/hossam/__init__.py +0 -3
- hossam-0.2.1/hossam/util.py +0 -636
- hossam-0.2.1/hossam.egg-info/PKG-INFO +0 -75
- hossam-0.2.1/hossam.egg-info/SOURCES.txt +0 -15
- hossam-0.2.1/hossam.egg-info/not-zip-safe +0 -1
- hossam-0.2.1/pyproject.toml +0 -3
- hossam-0.2.1/setup.cfg +0 -7
- hossam-0.2.1/setup.py +0 -41
- {hossam-0.2.1 → hossam-0.3.19}/LICENSE +0 -0
- {hossam-0.2.1 → hossam-0.3.19}/hossam.egg-info/dependency_links.txt +0 -0
- {hossam-0.2.1 → hossam-0.3.19}/hossam.egg-info/top_level.txt +0 -0
hossam-0.3.19/PKG-INFO
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hossam
|
|
3
|
+
Version: 0.3.19
|
|
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
|
+
Dynamic: license-file
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
title: 🎓 Hossam Data Helper
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
# 🎓 Hossam Data Helper
|
|
45
|
+
|
|
46
|
+
[](https://www.python.org/downloads/)
|
|
47
|
+
[](https://opensource.org/licenses/MIT)
|
|
48
|
+
[](https://pypi.org/project/hossam/)
|
|
49
|
+
[](https://py.hossam.kr)
|
|
50
|
+
|
|
51
|
+
**Hossam**은 데이터 분석, 시각화, 통계 처리를 위한 종합 헬퍼 라이브러리입니다.
|
|
52
|
+
|
|
53
|
+
아이티윌(ITWILL)에서 진행 중인 머신러닝 및 데이터 분석 수업을 위해 개발되었으며, 이광호 강사의 강의에서 활용됩니다.
|
|
54
|
+
|
|
55
|
+
## ✨ 주요 특징
|
|
56
|
+
|
|
57
|
+
- 📊 **풍부한 시각화**: 25+ 시각화 함수 (Seaborn/Matplotlib 기반)
|
|
58
|
+
- 🎯 **통계 분석**: 회귀, 분류, 시계열 분석 도구
|
|
59
|
+
- 📦 **샘플 데이터**: 학습용 데이터셋 즉시 로드
|
|
60
|
+
- 🔧 **데이터 전처리**: 결측치 처리, 이상치 탐지, 스케일링
|
|
61
|
+
- 🤖 **MCP 서버**: VSCode/Copilot과 통합 가능한 Model Context Protocol 지원
|
|
62
|
+
- 📈 **교육용 최적화**: 데이터 분석 교육에 특화된 설계
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 📦 설치
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install hossam
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**요구사항**: Python 3.8 이상
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 🚀 빠른 시작
|
|
77
|
+
|
|
78
|
+
### 샘플 데이터 로드
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from hossam import load_data, load_info
|
|
82
|
+
|
|
83
|
+
# 사용 가능한 데이터셋 확인
|
|
84
|
+
datasets = load_info()
|
|
85
|
+
|
|
86
|
+
# 데이터 로드
|
|
87
|
+
df = load_data('AD_SALES')
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 간단한 시각화
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from hossam import hs_plot
|
|
94
|
+
import pandas as pd
|
|
95
|
+
import numpy as np
|
|
96
|
+
|
|
97
|
+
df = pd.DataFrame({
|
|
98
|
+
'x': np.random.randn(100),
|
|
99
|
+
'y': np.random.randn(100),
|
|
100
|
+
'category': np.random.choice(['A', 'B', 'C'], 100)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
# 산점도
|
|
104
|
+
hs_plot.scatterplot(df=df, xname='x', yname='y', hue='category')
|
|
105
|
+
|
|
106
|
+
# 박스플롯
|
|
107
|
+
hs_plot.boxplot(df=df, xname='category', yname='x')
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 🤖 MCP Server
|
|
113
|
+
|
|
114
|
+
Hossam은 **Model Context Protocol(MCP)** 기반 서버로도 작동하며, VSCode Copilot/Cline과 통합하여 데이터 분석 코드를 자동 생성할 수 있습니다.
|
|
115
|
+
|
|
116
|
+
### 빠른 시작
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# 서버 시작
|
|
120
|
+
hossam-mcp
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### VSCode + Copilot 연동
|
|
124
|
+
|
|
125
|
+
VSCode에서 Copilot과 함께 사용하려면 `.vscode/settings.json` 설정이 필요합니다.
|
|
126
|
+
|
|
127
|
+
**Copilot Chat에서 사용:**
|
|
128
|
+
```
|
|
129
|
+
@hossam 이 DataFrame의 결측치를 분석하고 처리하는 코드 작성해줘
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**설정 가이드:**
|
|
133
|
+
- [`.vscode/settings.json` 완성형 샘플](https://py.hossam.kr/guides/vscode-settings-sample/) ⭐
|
|
134
|
+
- [VSCode + Copilot 연동 상세](https://py.hossam.kr/guides/vscode-copilot-integration/)
|
|
135
|
+
- [MCP 서버 사용법](https://py.hossam.kr/guides/mcp/)
|
|
136
|
+
- [Copilot Chat 프롬프트 예시](https://py.hossam.kr/guides/copilot-prompts/)
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 📚 전체 문서
|
|
141
|
+
|
|
142
|
+
**완전한 API 문서와 가이드는 [py.hossam.kr](https://py.hossam.kr)에서 확인하세요.**
|
|
143
|
+
|
|
144
|
+
### 주요 모듈
|
|
145
|
+
|
|
146
|
+
- **hs_plot**: 25+ 시각화 함수 (선 그래프, 산점도, 히스토그램, 박스플롯, 히트맵 등)
|
|
147
|
+
- **hs_stats**: 회귀/분류 분석, 교차검증, 정규성 검정, 상관분석 등
|
|
148
|
+
- **hs_prep**: 결측치 처리, 이상치 탐지, 스케일링, 인코딩
|
|
149
|
+
- **hs_gis**: GIS 데이터 로드 및 시각화 (대한민국 지도 지원)
|
|
150
|
+
- **hs_classroom**: 학습용 이진분류, 다중분류, 회귀 데이터 생성
|
|
151
|
+
- **hs_util**: 예쁜 테이블 출력, 그리드 서치 등
|
|
152
|
+
|
|
153
|
+
자세한 사용법은 [API 문서](https://py.hossam.kr/api/hossam/)를 참고하세요.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 🎓 예제
|
|
158
|
+
|
|
159
|
+
### 결측치 분석
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
from hossam import hs_prep
|
|
163
|
+
|
|
164
|
+
# 결측치 정보 확인
|
|
165
|
+
hs_prep.hs_missing_values(df)
|
|
166
|
+
|
|
167
|
+
# 결측치 시각화
|
|
168
|
+
hs_prep.hs_missing_values_barplot(df)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 회귀 분석
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
from hossam import hs_stats
|
|
175
|
+
|
|
176
|
+
# 단순 선형 회귀
|
|
177
|
+
result = hs_stats.hs_simple_regression(df, xname='x', yname='y', plot=True)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### 상관분석 히트맵
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
from hossam import hs_plot
|
|
184
|
+
|
|
185
|
+
hs_plot.heatmap(df=df, annot=True, cmap='coolwarm')
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
더 많은 예제는 [문서 사이트](https://py.hossam.kr)를 참고하세요.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## 📄 라이선스
|
|
193
|
+
|
|
194
|
+
이 프로젝트는 MIT 라이선스를 따릅니다. 자유롭게 사용, 수정, 배포할 수 있습니다.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## 🔗 링크
|
|
199
|
+
|
|
200
|
+
- **문서**: [py.hossam.kr](https://py.hossam.kr)
|
|
201
|
+
- **PyPI**: [pypi.org/project/hossam](https://pypi.org/project/hossam/)
|
|
202
|
+
- **강사**: 이광호 (ITWILL 머신러닝 및 데이터 분석)
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
**Made with ❤️ for Data Science Education**
|
hossam-0.3.19/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 🎓 Hossam Data Helper
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# 🎓 Hossam Data Helper
|
|
6
|
+
|
|
7
|
+
[](https://www.python.org/downloads/)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
[](https://pypi.org/project/hossam/)
|
|
10
|
+
[](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
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install hossam
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**요구사항**: Python 3.8 이상
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 🚀 빠른 시작
|
|
38
|
+
|
|
39
|
+
### 샘플 데이터 로드
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from hossam import load_data, load_info
|
|
43
|
+
|
|
44
|
+
# 사용 가능한 데이터셋 확인
|
|
45
|
+
datasets = load_info()
|
|
46
|
+
|
|
47
|
+
# 데이터 로드
|
|
48
|
+
df = load_data('AD_SALES')
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 간단한 시각화
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from hossam import hs_plot
|
|
55
|
+
import pandas as pd
|
|
56
|
+
import numpy as np
|
|
57
|
+
|
|
58
|
+
df = pd.DataFrame({
|
|
59
|
+
'x': np.random.randn(100),
|
|
60
|
+
'y': np.random.randn(100),
|
|
61
|
+
'category': np.random.choice(['A', 'B', 'C'], 100)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
# 산점도
|
|
65
|
+
hs_plot.scatterplot(df=df, xname='x', yname='y', hue='category')
|
|
66
|
+
|
|
67
|
+
# 박스플롯
|
|
68
|
+
hs_plot.boxplot(df=df, xname='category', yname='x')
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 🤖 MCP Server
|
|
74
|
+
|
|
75
|
+
Hossam은 **Model Context Protocol(MCP)** 기반 서버로도 작동하며, VSCode Copilot/Cline과 통합하여 데이터 분석 코드를 자동 생성할 수 있습니다.
|
|
76
|
+
|
|
77
|
+
### 빠른 시작
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# 서버 시작
|
|
81
|
+
hossam-mcp
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### VSCode + Copilot 연동
|
|
85
|
+
|
|
86
|
+
VSCode에서 Copilot과 함께 사용하려면 `.vscode/settings.json` 설정이 필요합니다.
|
|
87
|
+
|
|
88
|
+
**Copilot Chat에서 사용:**
|
|
89
|
+
```
|
|
90
|
+
@hossam 이 DataFrame의 결측치를 분석하고 처리하는 코드 작성해줘
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**설정 가이드:**
|
|
94
|
+
- [`.vscode/settings.json` 완성형 샘플](https://py.hossam.kr/guides/vscode-settings-sample/) ⭐
|
|
95
|
+
- [VSCode + Copilot 연동 상세](https://py.hossam.kr/guides/vscode-copilot-integration/)
|
|
96
|
+
- [MCP 서버 사용법](https://py.hossam.kr/guides/mcp/)
|
|
97
|
+
- [Copilot Chat 프롬프트 예시](https://py.hossam.kr/guides/copilot-prompts/)
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 📚 전체 문서
|
|
102
|
+
|
|
103
|
+
**완전한 API 문서와 가이드는 [py.hossam.kr](https://py.hossam.kr)에서 확인하세요.**
|
|
104
|
+
|
|
105
|
+
### 주요 모듈
|
|
106
|
+
|
|
107
|
+
- **hs_plot**: 25+ 시각화 함수 (선 그래프, 산점도, 히스토그램, 박스플롯, 히트맵 등)
|
|
108
|
+
- **hs_stats**: 회귀/분류 분석, 교차검증, 정규성 검정, 상관분석 등
|
|
109
|
+
- **hs_prep**: 결측치 처리, 이상치 탐지, 스케일링, 인코딩
|
|
110
|
+
- **hs_gis**: GIS 데이터 로드 및 시각화 (대한민국 지도 지원)
|
|
111
|
+
- **hs_classroom**: 학습용 이진분류, 다중분류, 회귀 데이터 생성
|
|
112
|
+
- **hs_util**: 예쁜 테이블 출력, 그리드 서치 등
|
|
113
|
+
|
|
114
|
+
자세한 사용법은 [API 문서](https://py.hossam.kr/api/hossam/)를 참고하세요.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 🎓 예제
|
|
119
|
+
|
|
120
|
+
### 결측치 분석
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from hossam import hs_prep
|
|
124
|
+
|
|
125
|
+
# 결측치 정보 확인
|
|
126
|
+
hs_prep.hs_missing_values(df)
|
|
127
|
+
|
|
128
|
+
# 결측치 시각화
|
|
129
|
+
hs_prep.hs_missing_values_barplot(df)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### 회귀 분석
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
from hossam import hs_stats
|
|
136
|
+
|
|
137
|
+
# 단순 선형 회귀
|
|
138
|
+
result = hs_stats.hs_simple_regression(df, xname='x', yname='y', plot=True)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 상관분석 히트맵
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
from hossam import hs_plot
|
|
145
|
+
|
|
146
|
+
hs_plot.heatmap(df=df, annot=True, cmap='coolwarm')
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
더 많은 예제는 [문서 사이트](https://py.hossam.kr)를 참고하세요.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 📄 라이선스
|
|
154
|
+
|
|
155
|
+
이 프로젝트는 MIT 라이선스를 따릅니다. 자유롭게 사용, 수정, 배포할 수 있습니다.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## 🔗 링크
|
|
160
|
+
|
|
161
|
+
- **문서**: [py.hossam.kr](https://py.hossam.kr)
|
|
162
|
+
- **PyPI**: [pypi.org/project/hossam](https://pypi.org/project/hossam/)
|
|
163
|
+
- **강사**: 이광호 (ITWILL 머신러닝 및 데이터 분석)
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
**Made with ❤️ for Data Science Education**
|
|
Binary file
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
from .data_loader import load_data, load_info
|
|
2
|
+
from .hs_stats import oneway_anova
|
|
3
|
+
from matplotlib import pyplot as plt
|
|
4
|
+
from matplotlib import font_manager as fm
|
|
5
|
+
from importlib.resources import files, as_file
|
|
6
|
+
from importlib.metadata import version
|
|
7
|
+
from types import SimpleNamespace
|
|
8
|
+
import sys
|
|
9
|
+
import warnings
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
__version__ = version("hossam")
|
|
13
|
+
except Exception:
|
|
14
|
+
__version__ = "develop"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
hs_fig = SimpleNamespace(
|
|
18
|
+
dpi=200,
|
|
19
|
+
width=800,
|
|
20
|
+
height=450,
|
|
21
|
+
font_size=9.5,
|
|
22
|
+
font_weight="normal",
|
|
23
|
+
frame_width=0.7,
|
|
24
|
+
line_width=1.5,
|
|
25
|
+
grid_alpha=0.3,
|
|
26
|
+
grid_width=0.5,
|
|
27
|
+
fill_alpha=0.3
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
__all__ = ["load_data", "load_info", "hs_classroom", "hs_gis", "hs_plot", "hs_prep", "hs_stats", "hs_timeserise", "hs_util", "hs_fig"]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _init_korean_font():
|
|
34
|
+
"""
|
|
35
|
+
패키지에 포함된 한글 폰트를 기본 폰트로 설정합니다.
|
|
36
|
+
"""
|
|
37
|
+
font_file = "NotoSansKR-Regular.ttf"
|
|
38
|
+
try:
|
|
39
|
+
# 패키지 리소스에서 폰트 파일 경로 확보
|
|
40
|
+
with as_file(files("hossam") / font_file) as font_path:
|
|
41
|
+
fm.fontManager.addfont(str(font_path))
|
|
42
|
+
fprop = fm.FontProperties(fname=str(font_path))
|
|
43
|
+
fname = fprop.get_name()
|
|
44
|
+
|
|
45
|
+
plt.rcParams.update({
|
|
46
|
+
"font.family": fname,
|
|
47
|
+
"font.size": hs_fig.font_size,
|
|
48
|
+
"font.weight": hs_fig.font_weight,
|
|
49
|
+
"axes.unicode_minus": False,
|
|
50
|
+
"text.antialiased": True,
|
|
51
|
+
"lines.antialiased": True,
|
|
52
|
+
"patch.antialiased": True,
|
|
53
|
+
"figure.dpi": hs_fig.dpi,
|
|
54
|
+
"savefig.dpi": hs_fig.dpi * 2,
|
|
55
|
+
"text.hinting": "auto",
|
|
56
|
+
"text.hinting_factor": 8,
|
|
57
|
+
"pdf.fonttype": 42,
|
|
58
|
+
"ps.fonttype": 42,
|
|
59
|
+
})
|
|
60
|
+
if sys.stdout.isatty():
|
|
61
|
+
print(
|
|
62
|
+
"\n✅ 시각화를 위한 한글 글꼴(NotoSansKR-Regular)이 자동 적용되었습니다."
|
|
63
|
+
)
|
|
64
|
+
return
|
|
65
|
+
except Exception as e:
|
|
66
|
+
warnings.warn(f"\n한글 폰트 초기화: 패키지 폰트 사용 실패 ({e}).")
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _init():
|
|
70
|
+
|
|
71
|
+
# 안내 메시지 (블릿 리스트)
|
|
72
|
+
messages = [
|
|
73
|
+
"📦 아이티윌 이광호 강사가 제작한 라이브러리를 사용중입니다.",
|
|
74
|
+
"📚 자세한 사용 방법은 https://py.hossam.kr 을 참고하세요.",
|
|
75
|
+
"📧 Email: leekh4232@gmail.com",
|
|
76
|
+
"🎬 Youtube: https://www.youtube.com/@hossam-codingclub",
|
|
77
|
+
"📝 Blog: https://blog.hossam.kr/",
|
|
78
|
+
f"🔖 Version: {__version__}",
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
# MCP/stdio 환경에서는 배너를 출력하지 않음 (stdout TTY일 때만 출력)
|
|
82
|
+
if sys.stdout.isatty():
|
|
83
|
+
for msg in messages:
|
|
84
|
+
print(f"{msg}")
|
|
85
|
+
|
|
86
|
+
_init_korean_font()
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
_init()
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# -------------------------------------------------------------
|
|
3
|
+
|
|
1
4
|
import requests
|
|
2
5
|
import json
|
|
3
6
|
from os.path import join, exists
|
|
4
7
|
from io import BytesIO
|
|
5
8
|
from pandas import DataFrame, read_csv, read_excel
|
|
6
|
-
|
|
7
|
-
from
|
|
9
|
+
from typing import Optional
|
|
10
|
+
from typing import Optional
|
|
8
11
|
|
|
9
12
|
BASE_URL = "https://data.hossam.kr"
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
def
|
|
14
|
+
# -------------------------------------------------------------
|
|
15
|
+
def __get_df(path: str, index_col=None) -> DataFrame:
|
|
13
16
|
p = path.rfind(".")
|
|
14
17
|
exec = path[p+1:].lower()
|
|
15
18
|
|
|
@@ -32,7 +35,8 @@ def get_df(path: str, index_col=None) -> DataFrame:
|
|
|
32
35
|
info = read_excel(BytesIO(data_bytes), sheet_name='metadata', index_col=0)
|
|
33
36
|
#print("\033[94m[metadata]\033[0m")
|
|
34
37
|
print()
|
|
35
|
-
|
|
38
|
+
from .util import hs_pretty_table
|
|
39
|
+
hs_pretty_table(info)
|
|
36
40
|
print()
|
|
37
41
|
except Exception:
|
|
38
42
|
print(f"\033[91m[!] Cannot read metadata\033[0m")
|
|
@@ -43,7 +47,8 @@ def get_df(path: str, index_col=None) -> DataFrame:
|
|
|
43
47
|
info = read_excel(path, sheet_name='metadata', index_col=0)
|
|
44
48
|
#print("\033[94m[metadata]\033[0m")
|
|
45
49
|
print()
|
|
46
|
-
|
|
50
|
+
from .util import hs_pretty_table
|
|
51
|
+
hs_pretty_table(info)
|
|
47
52
|
print()
|
|
48
53
|
except:
|
|
49
54
|
print(f"\033[91m[!] Cannot read metadata\033[0m")
|
|
@@ -52,7 +57,8 @@ def get_df(path: str, index_col=None) -> DataFrame:
|
|
|
52
57
|
|
|
53
58
|
return df
|
|
54
59
|
|
|
55
|
-
|
|
60
|
+
# -------------------------------------------------------------
|
|
61
|
+
def __get_data_url(key: str, local: str = None) -> str:
|
|
56
62
|
global BASE_URL
|
|
57
63
|
|
|
58
64
|
path = None
|
|
@@ -87,8 +93,23 @@ def get_data_url(key: str, local: str = None) -> str:
|
|
|
87
93
|
|
|
88
94
|
return path, info.get('desc'), info.get('index')
|
|
89
95
|
|
|
96
|
+
# -------------------------------------------------------------
|
|
97
|
+
def load_info(search: str = None, local: str = None) -> DataFrame:
|
|
98
|
+
"""메타데이터에서 사용 가능한 데이터셋 정보를 로드한다.
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
search (str, optional): 이름 필터 문자열. 포함하는 항목만 반환.
|
|
102
|
+
local (str, optional): 로컬 메타데이터 경로. None이면 원격(BASE_URL) 사용.
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
DataFrame: name, chapter, desc, url 컬럼을 갖는 테이블
|
|
90
106
|
|
|
91
|
-
|
|
107
|
+
Examples:
|
|
108
|
+
>>> from hossam.data_loader import load_info
|
|
109
|
+
>>> info = load_info()
|
|
110
|
+
>>> list(info.columns)
|
|
111
|
+
['name', 'chapter', 'desc', 'url']
|
|
112
|
+
"""
|
|
92
113
|
global BASE_URL
|
|
93
114
|
|
|
94
115
|
path = None
|
|
@@ -135,11 +156,24 @@ def load_info(search: str = None, local: str = None):
|
|
|
135
156
|
|
|
136
157
|
return my_df2
|
|
137
158
|
|
|
159
|
+
# -------------------------------------------------------------
|
|
160
|
+
def load_data(key: str, local: str = None) -> Optional[DataFrame]:
|
|
161
|
+
"""키로 지정된 데이터셋을 로드한다.
|
|
138
162
|
|
|
139
|
-
|
|
163
|
+
Args:
|
|
164
|
+
key (str): 메타데이터에 정의된 데이터 식별자(파일명 또는 별칭)
|
|
165
|
+
local (str, optional): 로컬 메타데이터 경로. None이면 원격(BASE_URL) 사용.
|
|
166
|
+
|
|
167
|
+
Returns:
|
|
168
|
+
DataFrame | None: 성공 시 데이터프레임, 실패 시 None
|
|
169
|
+
|
|
170
|
+
Examples:
|
|
171
|
+
>>> from hossam.data_loader import load_data
|
|
172
|
+
>>> df = load_data('AD_SALES') # 메타데이터에 해당 키가 있어야 함
|
|
173
|
+
"""
|
|
140
174
|
index = None
|
|
141
175
|
try:
|
|
142
|
-
url, desc, index =
|
|
176
|
+
url, desc, index = __get_data_url(key, local=local)
|
|
143
177
|
except Exception as e:
|
|
144
178
|
try:
|
|
145
179
|
print(f"\033[91m{str(e)}\033[0m")
|
|
@@ -153,7 +187,7 @@ def load_data(key: str, local: str = None):
|
|
|
153
187
|
df = None
|
|
154
188
|
|
|
155
189
|
try:
|
|
156
|
-
df =
|
|
190
|
+
df = __get_df(url, index_col=index)
|
|
157
191
|
except Exception as e:
|
|
158
192
|
try:
|
|
159
193
|
print(f"\033[91m{str(e)}\033[0m")
|
|
@@ -162,9 +196,4 @@ def load_data(key: str, local: str = None):
|
|
|
162
196
|
return
|
|
163
197
|
|
|
164
198
|
|
|
165
|
-
return df
|
|
166
|
-
|
|
167
|
-
if __name__ == "__main__":
|
|
168
|
-
print(load_info())
|
|
169
|
-
df = load_data("boston")
|
|
170
|
-
my_pretty_table(df)
|
|
199
|
+
return df
|