hossam 0.4.4__py3-none-any.whl → 0.4.5__py3-none-any.whl

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/data_loader.py CHANGED
@@ -6,8 +6,8 @@ import json
6
6
  from os.path import join, exists
7
7
  from io import BytesIO
8
8
  from pandas import DataFrame, read_csv, read_excel
9
- from typing import Optional
10
- from typing import Optional
9
+ from typing import Optional, Tuple, Any
10
+ from .hs_util import pretty_table
11
11
 
12
12
  BASE_URL = "https://data.hossam.kr"
13
13
 
@@ -35,8 +35,7 @@ def __get_df(path: str, index_col=None) -> DataFrame:
35
35
  info = read_excel(BytesIO(data_bytes), sheet_name='metadata', index_col=0)
36
36
  #print("\033[94m[metadata]\033[0m")
37
37
  print()
38
- from .util import hs_pretty_table
39
- hs_pretty_table(info)
38
+ pretty_table(info)
40
39
  print()
41
40
  except Exception:
42
41
  #print(f"\033[91m[!] Cannot read metadata\033[0m")
@@ -48,8 +47,7 @@ def __get_df(path: str, index_col=None) -> DataFrame:
48
47
  info = read_excel(path, sheet_name='metadata', index_col=0)
49
48
  #print("\033[94m[metadata]\033[0m")
50
49
  print()
51
- from .util import hs_pretty_table
52
- hs_pretty_table(info)
50
+ pretty_table(info)
53
51
  print()
54
52
  except:
55
53
  #print(f"\033[91m[!] Cannot read metadata\033[0m")
@@ -60,7 +58,7 @@ def __get_df(path: str, index_col=None) -> DataFrame:
60
58
  return df
61
59
 
62
60
  # -------------------------------------------------------------
63
- def __get_data_url(key: str, local: str = None) -> str:
61
+ def __get_data_url(key: str, local: str | None = None) -> Tuple[str, Any, Any]:
64
62
  global BASE_URL
65
63
 
66
64
  path = None
@@ -96,7 +94,7 @@ def __get_data_url(key: str, local: str = None) -> str:
96
94
  return path, info.get('desc'), info.get('index')
97
95
 
98
96
  # -------------------------------------------------------------
99
- def load_info(search: str = None, local: str = None) -> DataFrame:
97
+ def load_info(search: str | None = None, local: str | None = None) -> DataFrame:
100
98
  """메타데이터에서 사용 가능한 데이터셋 정보를 로드한다.
101
99
 
102
100
  Args:
@@ -160,7 +158,7 @@ def load_info(search: str = None, local: str = None) -> DataFrame:
160
158
  return my_df2
161
159
 
162
160
  # -------------------------------------------------------------
163
- def load_data(key: str, local: str = None) -> Optional[DataFrame]:
161
+ def load_data(key: str, local: str | None = None) -> Optional[DataFrame]:
164
162
  """키로 지정된 데이터셋을 로드한다.
165
163
 
166
164
  Args:
hossam/hs_gis.py CHANGED
@@ -22,10 +22,10 @@ def __geocode_item(session: requests.Session, index: int, addr: str, key: str) -
22
22
  """단일 주소를 VWorld API로 지오코딩합니다.
23
23
 
24
24
  Args:
25
- session: 재사용할 `requests.Session` 인스턴스.
26
- index: 입력 데이터의 인덱스(로그용).
27
- addr: 지오코딩할 도로명 주소 문자열.
28
- key: VWorld API 키.
25
+ session (requests.Session): 재사용할 `requests.Session` 인스턴스.
26
+ index (int): 입력 데이터의 인덱스(로그용).
27
+ addr (str): 지오코딩할 도로명 주소 문자열.
28
+ key (str): VWorld API 키.
29
29
 
30
30
  Returns:
31
31
  (latitude, longitude) 튜플.
@@ -90,12 +90,12 @@ def geocode(df: DataFrame, addr: str, key: str) -> DataFrame:
90
90
  """주소 컬럼을 일괄 지오코딩하여 위도/경도 컬럼을 추가합니다.
91
91
 
92
92
  Args:
93
- df: 입력 `DataFrame`.
94
- addr: 주소가 들어있는 컬럼명.
95
- key: VWorld API 키.
93
+ df (DataFrame): 입력 `DataFrame`.
94
+ addr (str): 주소가 들어있는 컬럼명.
95
+ key (str): VWorld API 키.
96
96
 
97
97
  Returns:
98
- 위도(`latitude`), 경도(`longitude`) 컬럼이 추가된 `DataFrame`.
98
+ DataFrame: 위도(`latitude`), 경도(`longitude`) 컬럼이 추가된 `DataFrame`.
99
99
 
100
100
  Raises:
101
101
  Exception: 지오코딩 과정에서 발생한 예외를 전파합니다.
@@ -164,11 +164,11 @@ def load_shape(path: str, info: bool = True) -> GeoDataFrame:
164
164
  """Shapefile을 읽어 `GeoDataFrame`으로 로드합니다.
165
165
 
166
166
  Args:
167
- path: 읽을 Shapefile(.shp) 경로.
168
- info: True면 데이터 프리뷰와 통계를 출력.
167
+ path (str): 읽을 Shapefile(.shp) 경로.
168
+ info (bool): True면 데이터 프리뷰와 통계를 출력.
169
169
 
170
170
  Returns:
171
- 로드된 `GeoDataFrame`.
171
+ GeoDataFrame: 로드된 `GeoDataFrame`.
172
172
 
173
173
  Raises:
174
174
  FileNotFoundError: 파일이 존재하지 않는 경우.
@@ -186,7 +186,7 @@ def load_shape(path: str, info: bool = True) -> GeoDataFrame:
186
186
 
187
187
  if info:
188
188
  print("\n✅ 테이블 정보")
189
- pretty_table(data.info(), tablefmt="pretty")
189
+ pretty_table(data.info(), tablefmt="pretty") # type: ignore
190
190
 
191
191
  print("\n✅ 상위 5개 행")
192
192
  pretty_table(data.head(), tablefmt="pretty")
@@ -226,12 +226,11 @@ def save_shape(
226
226
  - 확장자 없으면 .shp로 저장
227
227
 
228
228
  Args:
229
- gdf: 저장할 `GeoDataFrame` 또는 `DataFrame`.
230
- path: 저장 경로(.shp 또는 .gpkg, 확장자 없으면 .shp 자동 추가).
231
- crs: 좌표계 문자열(e.g., "EPSG:4326"). 미지정 시 WGS84.
232
- lat_col: DataFrame 입력 시 위도 컬럼명.
233
- lon_col: DataFrame 입력 시 경도 컬럼명.
234
-
229
+ gdf (GeoDataFrame | DataFrame): 저장할 `GeoDataFrame` 또는 `DataFrame`.
230
+ path (str): 저장 경로(.shp 또는 .gpkg, 확장자 없으면 .shp 자동 추가).
231
+ crs (str | None): 좌표계 문자열(e.g., "EPSG:4326"). 미지정 시 WGS84.
232
+ lat_col (str): DataFrame 입력 시 위도 컬럼명.
233
+ lon_col (str): DataFrame 입력 시 경도 컬럼명.
235
234
  Returns:
236
235
  None: 파일을 저장하고 반환값이 없습니다.
237
236