Data Preprocess & EDA(2) - Feature Engineering
2021. 1. 30. 10:26ㆍ[AI]/Data Science Fundamentals
<Learned Stuff>
Key points
- Feature Engineering
- 데이터셋에 존재하는 Feature들을 재조합하여 새로운 Feature를 만드는 것
개념
- NA, Null, NaN 차이
- object --> int
- Indexing
<New Stuff>
[Na, Null, NaN 의 차이]
-
파이썬에서는 NaN(NA)와 Null을 '정해지지 않은 값'의 의미로 같이 사용한다고 함
-
(R에서의 NA는 '잘못된 값', Null은 '아직 정해지지 않은 값', 서로 다른 의미를 가짐)
[DataFrame column중 'object' 형태를 'int'형태로 바꾸는 과정]
# column type 중 'object'인 것만 가져오기
labels = df.columns #header 를 labels에 저장
new_labels= []
for i in labels :
if df[i].dtypes == 'object' :
new_labels.append(i) #해당 header의 data 값들 type 이 'object'면 new_labels 에 append
# 'object' 형태의 column을 apply(toint) 시키기
for i in new_labels :
df[i] = df[i].apply(toint) #toint 는 int 형태로 바꿔주는 함수!
[Indexing 할 때 주의할 점]
- dataframe indexing 할 때 loc 나 iloc 쓰는 것을 권장
df.loc[indexer] # you know automatically that df.loc is selecting rows
df[indexer] # not clear if df[indexer] will select rows or columns
728x90
'[AI] > Data Science Fundamentals' 카테고리의 다른 글
[Data Science Fundamentals] - Mindmap (0) | 2021.01.30 |
---|---|
Data Preprocess & EDA(1) - EDA(Exploratory Data Analysis) (0) | 2021.01.30 |
Data Preprocess & EDA(3) - Data Manipulation (0) | 2021.01.30 |
Data Preprocess & EDA(4) - Data Visualization (0) | 2021.01.30 |
Statistic(1) - Hypothesis Test(1) (0) | 2021.01.30 |