# rename() 함수로 열 이름 변경
data.rename(columns={'DistanceFromHome' : 'Distance',
'EmployeeNumber' : 'EmpNo',
'JobSatisfaction' : 'JobSat',
'MonthlyIncome' : 'M_Income',
'PercentSalaryHike' : 'PctSalHike',
'TotalWorkingYears' : 'TotWY'}, inplace=True)
# 확인
data.head()
df.drop('삭제할 칼럼 이름' , axis = 1 , inplace = True)
axis = 1 이면 열을 삭제 0 이면 행 삭제
inplace = True 는 실제로 데이터프레임에 적용 하는 것이다
삭제할 칼럼이 2개 이상일 경우 리스트 로 만든다 ['칼럼1' , '칼럼2'.....]
data2['칼럼 이름'] = value
data2.loc [조건 , "칼럼 이름"] = value
data2['칼럼명'] = np.where(data2['칼럼명']조건 , True , False)
data['Gen'] = data['Gen'].map({'Male' : 1 , 'Female' : 0})
data.head()
age_group = pd.cut(data2['Age'] , 3)
age_group.value_counts()
age_group = pd.cut(data2['Age'] , 3 , labels = ['a','b','c'])
age_group.value_counts()
# 나이를 다음 구간으로 분할합니다.
# 'young' : =< 40
# 'junior' : 40 < =< 50
# 'senior' : 50 <
age_group = pd.cut(data2['Age'], bins =[0, 40, 50, 100] , labels = ['young','junior','senior'])
age_group.value_counts()