데이터분석

pandas factorize

늘근이 2018. 8. 15. 08:58
# function to obtain Categorical Features
def _get_categorical_features(df):
    feats = [col for col in list(df.columns) if df[col].dtype == 'object']
    return feats

# function to factorize categorical features
def _factorize_categoricals(df, cats):
    for col in cats:
        df[col], _ = pd.factorize(df[col])
    return df 


'데이터분석' 카테고리의 다른 글

edge modes  (0) 2018.09.13
ADP 합격후기  (2) 2018.08.27
category변수 처리  (0) 2018.08.15
Simple LightGBM 예제  (0) 2018.08.08
[링크] tsne 이용  (0) 2018.07.29