hossam.my_util¶
hossam.my_util ¶
load_info ¶
load_info(search=None, local=None)
메타데이터에서 사용 가능한 데이터셋 정보를 로드한다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
search
|
str
|
이름 필터 문자열. 포함하는 항목만 반환. |
None
|
local
|
str
|
로컬 메타데이터 경로. None이면 원격(BASE_URL) 사용. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
DataFrame |
DataFrame
|
name, desc, url 컬럼을 갖는 테이블 |
Examples:
from hossam import *
info = load_info()
list(info.columns) #['name', 'desc', 'url']
my_packages ¶
my_packages()
현재 파이썬 인터프리터에 설치된 모든 패키지의 이름과 버전을 패키지 이름순으로 정렬하여 pandas DataFrame으로 반환합니다. Returns: pd.DataFrame: columns=['name', 'version']
make_normalize_values ¶
make_normalize_values(mean, std, size=100, round=2)
정규분포를 따르는 데이터를 생성한다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mean
|
float
|
평균 |
required |
std
|
float
|
표준편차 |
required |
size
|
int
|
데이터 크기. Defaults to 100. |
100
|
round
|
int
|
소수점 반올림 자리수. Defaults to 2. |
2
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: 정규분포를 따르는 데이터 |
Examples:
from hossam import *
x = hs.util.make_normalize_values(mean=0.0, std=1.0, size=100)
make_normalize_data ¶
make_normalize_data(
means=None, stds=None, sizes=None, rounds=2
)
정규분포를 따르는 데이터프레임을 생성한다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
means
|
list
|
평균 목록. Defaults to [0, 0, 0]. |
None
|
stds
|
list
|
표준편차 목록. Defaults to [1, 1, 1]. |
None
|
sizes
|
list
|
데이터 크기 목록. Defaults to [100, 100, 100]. |
None
|
rounds
|
int
|
반올림 자리수. Defaults to 2. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
DataFrame |
DataFrame
|
정규분포를 따르는 데이터프레임 |
pretty_table ¶
pretty_table(data, tablefmt='simple', headers='keys')
tabulate를 사용해 DataFrame을 단순 표 형태로 출력한다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
출력할 데이터프레임 |
required |
tablefmt
|
str
|
|
'simple'
|
headers
|
str | list
|
헤더 지정 방식. Defaults to "keys". |
'keys'
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Examples:
from hossam import *
from pandas import DataFrame
my_util.pretty_table(DataFrame({"a":[1,2],"b":[3,4]}))
load_data ¶
load_data(key, index_col=None, local=None)
데이터 키를 통해 데이터를 로드한 뒤 기본 전처리/출력을 수행한다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
데이터 키 (metadata.json에 정의된 데이터 식별자) |
required |
index_col
|
str
|
인덱스로 설정할 컬럼명. Defaults to None. |
None
|
local
|
str
|
원격 데이터 대신 로컬 메타데이터 경로를 사용한다. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
DataFrame |
DataFrame
|
전처리(인덱스 설정, 카테고리 변환)가 완료된 데이터프레임 |
Examples:
from hossam import *
df = my_util.load_data("AD_SALES")
is_2d ¶
is_2d(x)
주어진 객체가 2차원 리스트인지 확인합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
확인할 객체 |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
객체가 2차원 리스트인 경우 True, 그렇지 않은 경우 False |