np.where

4879 단어 np.wherenp.where
import numpy as np
pred_label=np.where(pred>0.5, 1, 0)

#### 범주형 데이터의 처리 
#대상지역 생성
survey['대상지역'] = np.where(survey['TITLE'].str.contains('해외'), '해외', '기타')
#대상자유형
survey['대상자유형'] = '기타'
survey['대상자유형'] = np.where(survey['TITLE'].str.contains('일반인'), '일반인', survey['대상자유형'])
survey['대상자유형'] = np.where(survey['TITLE'].str.contains('소비자'), '소비자', survey['대상자유형'])
features_cols.extend(['대상지역', '대상자유형'])

cr1 = churn.InternetService=='Fiber optic'
cr2 = churn.InternetService=='DSL'
churn.InternetService = np.where(cr1, 2, np.where(cr2, 1, 0))

좋은 웹페이지 즐겨찾기