본문 바로가기

파이썬 통계 머신러닝

df.apply(lambda x: func(x)) : DF각 값들에 대해 함수 호출시 사용

(사용예시)

def func(x):

    if x == 'a':

        return 'type1'

    elif x == 'b':

        return 'type2'

 

df['value'].apply(lambda x: func(x))  # df['value'] 각각의 값들에 대해 func 함수 호출 실행