❤️여존슨- 박스콕스
from sklearn.preprocessing import power_transfrom
df['y'] = power_transform(df['col'])
df['b'] = power_transform(df['col'], method = box-cox )
from scipy import stats
yeo = stats.yeojohnson(df['col'])
box = stats.boxcox(df['col'])
❤️ 표준화1
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
# 하나의 컬럼만 표준화할때는 대괄호 두개
df['col2'] = scaler.fit_transform(df[['col']])
# 수치형 데이터프레임을 전부 표준화 할때
scaled_df = scaler.fit_transform(df)
❤️ 표준화2 - min-max표준화
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
df['col2'] = scaler.fit_transform(df[[col]])
❤️ 그룹바이
~ 별로 라고하면 ~라고 나온것을 묶기
# 조건을 걸 컬럼을 데이터프레임으로 유지하기위해 대괄호 두개
df = df.groupby(['city', 'f4'])[['f5']].mean()
오름차순 : ascending = True (작은것 -> 큰것)
내림차순 : ascending = False (큰것 -> 작은것)
❤️ 요일
df.dayofweek
# 주말
df['weekend'] = df['dayofweek'] >= 5
# 평일
df['weekday'] = ~df['dayofweek']
❤️ 주 단위
df_w = df.resample('W', on = 'Date')['Sales'].sum()
❤️ 시차
df['lag'] = df['col'].shift(1)
❤️ pd.melt : 열로 합치기
❤️ 정수형 : int
❤️ 반올림 : round
❤️ 올림 : np.ceil
❤️ 내림 : np.floor
❤️ 버림 : np.trunc
❤️ df['col'] = np.where[cond, 맞을시, 아닐시]
❤️pd.merge(left = '', right = '' , on = 'f4', how='')
'빅데이터 분석기사 > 정리' 카테고리의 다른 글
컬럼안에 있는 값을 다른 값 대체 (0) | 2025.06.21 |
---|---|
결측값을 두 컬럼이 같은 값을 가진 평균으로 대체하기 (0) | 2025.06.19 |
.idxmax() (0) | 2025.06.19 |
train_test_split, 오분류율, 정확도, 정밀도, MSE, RMSE, f1_score (0) | 2025.06.16 |
숫자형 컬럼만 뽑아서 상관계수 구하기 select_dtypes(include = ' ') (0) | 2025.06.15 |