728x90
def extract_year(row):
return row.split('-')[0]
df['year'] = df['date'].map(extract_year)
apply와 map 똑같네
df.job = df.job.map({"student":1,"developer":2,"teacher":3})
이건 apply는 못하는거
직업 데이터를 숫자로 바꾸기
student -> 1
df = df.applymap(np.around)
반올림하기
모든 값을 바꿀 땐 apply
하나하나는 map
728x90
'AI > Pandas 기초' 카테고리의 다른 글
13. 두개의 데이터프레임 합치기 (0) | 2020.04.24 |
---|---|
12. 컬럼 내 유니크한 값 뽑아내고 갯수 확인하기 (0) | 2020.04.24 |
10. apply 함수 활용 (0) | 2020.04.24 |
09. NaN 찾아서 다른 값으로 변경하기 (0) | 2020.04.24 |
08. 중복 데이터 삭제하기 (0) | 2020.04.24 |