문자를 숫자로 바꾸어 주는 방법은 One-Hot Encoding이 있다.

import numpy as np   
import pandas as pd   

fruit = pd.DataFrame({'name':['apple', 'banana', 'cherry', 'durian', np.nan],
                      'color':['red', 'yellow', 'red', 'green', np.nan]})

get_dummies

name column에는 4개의 고유한 데이터가 있다. 이것을 행으로 바꿔 있다 없다를 1과 0으로 원핫인코딩한다.

+ Recent posts