반응형
Notice
Recent Posts
Recent Comments
Link
관리 메뉴

bro's coding

AICE.DATA.PREPROCESSING 본문

[CERTIFICATION]/AICE

AICE.DATA.PREPROCESSING

givemebro 2023. 7. 26. 02:23
반응형
필요 라이브러리 임포트
import numpy as np
import pandas as pd

#파일 읽어오기
df = pd.read_csv(’data_v1.csv’)

#탐색적 데이터 분석
#상위 디폴트 5개 : df.head()

#하위 디폴트 5개 : df.tail()

#자료구조 파악 : df.info()

#데이터 인덱스 : df.index

#데이터 컬럼명 : df.columns

#데이터 Values : df.values

#Null 데이터 확인 : df.isnull().sum()

#통계 정보 : df.describe()

#데이터 전처리
#자료 구조 파악 info 사용(Row, column, Not-null, type)

#customerID는 필요 없으니 삭제

df.drop(’customerID’, axis =1 , inplace=True)

#범주형 문자 데이터 ⇒ 숫자 변환 필요

cond = (df[’TotalCharges’] == ‘ ‘)	(df[’TotalCharges’] == ‘’)
df[cond]로 결과 확인 위에 조건이 해당되는 것들이 있다는 거
df[’TotalCharges’].replace([’ ‘], [’0’], inplace=True)
df[’TotalCharges’] = df[’TotalCharges’].astype(float)
df[’Churn’].value_counts()
df[’Churn’].replace([’Yes’, ’No’], [1, 0], inplace=True)
#결측치 처리
#컬럼별 Null 값 얼마나 있는지 확인 : df.isnull.sum()

#결측치 처리
df.drop(’DeviceProtection’, axis=1, inplace=True)
df.dropna(inplace=True)
반응형

'[CERTIFICATION] > AICE' 카테고리의 다른 글

AICE.REF  (0) 2023.07.26
AICE.DNN  (0) 2023.07.26
AICE.NORMALIZITION  (0) 2023.07.26
AICE.ML  (0) 2023.07.26
AICE.DATA.PREPROCESSING  (0) 2023.07.26
AICE.DATA.VISUALIZITION  (0) 2023.07.26
Comments