Skip to main content

SKT Package

This is highly site dependent package. Resources are abstracted into package structure.

Usage

Hive metastore

from skt.ye import get_hms

c = get_hms()
c.get_partition_names("db", "table")
c.close()

Hash and unhash

from skt.lake import hash_s
from skt.lake import unhash_s

unhashed_list = ['0000000000']
hashed_list = hash_s(unhashed_list)
unhash_s(hashed_list)

Get pandas dataframe from parquet file in hdfs

from skt.ye import parquet_to_pandas

pandas_df = parquet_to_pandas(hdfs_path)

Save pandas dataframe as parquet in hdfs

from skt.ye import get_spark
from skt.ye import pandas_to_parquet

spark = get_spark()
pandas_to_parquet(pandas_df, hdfs_path, spark)  # we need spark for this operation
spark.stop()

Work with spark

from skt.ye import get_spark

spark = get_spark()
# do with spark session
spark.stop()

Work with spark-bigquery-connector

# SELECT
from skt.gcp import bq_table_to_pandas

pandas_df = bq_table_to_pandas("dataset", "table_name", ["col_1", "col_2"], "2020-01-01", "svc_mgmt_num is not null")
# INSERT 
from skt.gcp import pandas_to_bq_table

pandas_to_bq_table(pandas_df, "dataset", "table_name", "2020-03-01")

Send slack message

from skt.ye import slack_send

text = 'Hello'
username = 'airflow'
channel = '#leavemealone'
slack_send(text=text, username=username, channel=channel)
# Send dataframe as text
df = pd.DataFrame(data={'col1': [1, 2], 'col2': [3, 4]})
slack_send(text=df, username=username, channel=channel, dataframe=True)
# Send with the adot alarm bot instead of the airflow bot
slack_send(text=text, username=username, channel=channel, adot=True)

Send email

from skt.ye import send_email

send_email("subject", "body", "sender@sktelecom.com", "a@sktelecom.com,b@sktelecom.com", attachment="text to attach")

Download a file from GitLab

from skt.gitlab_utils import GitlabUtil

g = GitlabUtil()  # or GitlabUtil(token="...") outside YKS pods
byte_object = g.download_from_git("https://gitlab.tde.sktelecom.com/AIDP/skt/-/blob/master/README.md")

Get bigquery client

from skt.gcp import get_bigquery_client

bq = get_bigquery_client()
bq.query(query)

IPython BigQuery Magic

from skt.gcp import import_bigquery_ipython_magic

import_bigquery_ipython_magic()

query_params = {
    "p_1": "v_1",
    "dataset": "mnoai",
}
%% bq --params $query_params

SELECT c_1 
FROM {dataset}.user_logs
WHERE c_1 = @p_1

Use NES CLI

nes input_notebook_url -p k1 v1 -p k2 v2 -p k3 v3

Installation

$ pip install skt --upgrade

If you would like to install submodules for AIR

$ pip install skt[air] --upgrade

Develop

Create an issue first, then open a merge request on GitLab https://gitlab.tde.sktelecom.com/AIDP/skt

AIPS EDA tools

OVERVIEW

  • Modeling EDA 시 활용할 수 있는 기능의 공통 module
  • Modules

      1) EDA (Nuemric / Categorical variable)
         <br>
         <br>
    

1) EDA

1. Numeric variable EDA

  • def numeric_eda_plot
    Numeric feature에 대한 EDA Plot function
    
    Args. :
        - df           :   Pandas DataFrame 형태의 EDA대상 데이터
        - feature_list :   EDA 대상 feature list (df의 columns)
        - label_col    :   Label(or Hue) column
        - cols         :   Multi-plot 시 grid column 개수 (row 개수는 feature_list에 따라 자동으로 결정 됨)
        - n_samples    :   Label 별 sampling 할 개수 (default = -1(전수 데이터로 EDA할 경우))
        - plot_type    :   density or box (default = 'density')
        - stat_yn      :   기초 통계량 출력여부 (mean / min / max / 1q / 3q) (default : False)
        - figsize      :   (default : (7,4))
    
    Returns : 
        matplotlib.pyplot object

    Example : 
        fig = numeric_eda_plot(df, ['age'], 'answer', cols = 1, n_samples = 10000, plot_type='density', stat_yn=True, figsize = (7,4))
        fig
        
        if want to Save the EDA images,
        fig.savefig('filename')

2. Categorical variable EDA

  • def categorical_eda_plot
    Categorical feature에 대한 EDA Plot function
    
    Args. :
        - df           :   Pandas DataFrame 형태의 EDA대상 데이터
        - feature_list :   EDA 대상 feature list (df의 columns)
        - label_col    :   Label(or Hue) column
        - cols         :   Multi-plot 시 grid column 개수 (row 개수는 feature_list에 따라 자동으로 결정 됨)
        - n_samples    :   Label 별 sampling 할 개수 (default = -1(전수 데이터로 EDA할 경우))
        - figsize      :   (default : (7,4))
    
    Returns : 
        matplotlib.pyplot object


    Example : 
        Example : 
        fig = categorical_eda_plot(df, ['sex_cd'], 'answer', cols = 1, n_samples = 10000, figsize = (7,4))
        fig
        
        if want to Save the EDA images,
        fig.savefig('filename')
    

Metadata

Release files for skt 1.0.24

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for skt 1.0.24
File Size Uploaded Provenance Actions
skt-1.0.24.tar.gz 28.7 kB Without provenance Details for skt-1.0.24.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for skt 1.0.24
File Interpreter ABI Platform Actions
skt-1.0.24-py3-none-any.whl Python 3 none any Details for skt-1.0.24-py3-none-any.whl

Total release size: 58.2 kB

Release files / skt-1.0.24.tar.gz

Download URL skt-1.0.24.tar.gz
Size 28.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a332028c08ed3b6292b86aeb264694c301d412c37e22e117f9c8a3e461386d9f
BLAKE2b-256 checksum
How to use checksums
26e321b420d65d3f7c9c47c285f0ed0c33d078235255f31eaf3dbc4383cc5c64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release files / skt-1.0.24-py3-none-any.whl

Download URL skt-1.0.24-py3-none-any.whl
Size 29.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bbc7673bbdf582b5544a4632ee6ac8ca9bc2ea2f4af61820e63bdaf8e9ac9f77
BLAKE2b-256 checksum
How to use checksums
790de8ce293bb8d2b778d5174f98a1ddf612688630f75c43d3c7d83e438a45a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Security for skt 1.0.24

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.24 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page