반응형

참고: http://stackoverflow.com/questions/18194404/create-column-with-elif-in-pandas


특정 조건 주어서 pandas column 값 변경하기


def func(row):
    if row['mobile'] == 'mobile':
        return 'mobile'
    elif row['tablet'] =='tablet':
        return 'tablet' 
    else:
        return 'other'
 

df['combo'] = df.apply(func, axis=1) 

반응형

+ Recent posts