Hi there!

I am a student studying computer science.

AI/Pandas 기초

11. map, applymap 함수 활용

만능성구 2020. 4. 24. 19:29
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