반응형
Notice
Recent Posts
Recent Comments
Link
관리 메뉴

bro's coding

pandas.get_dummies.ont-hot-incoding 본문

[IT]/python.pandas

pandas.get_dummies.ont-hot-incoding

givemebro 2020. 4. 24. 09:19
반응형
# target을 one-hot-incoding한다
import numpy as np
import pandas as pd
from sklearn.datasets import load_iris

iris=load_iris()

data=np.c_[iris.data,pd.get_dummies(iris.target).values]
data

 

array([[5.1, 3.5, 1.4, ..., 1. , 0. , 0. ],
       [4.9, 3. , 1.4, ..., 1. , 0. , 0. ],
       [4.7, 3.2, 1.3, ..., 1. , 0. , 0. ],
       ...,
       [6.5, 3. , 5.2, ..., 0. , 0. , 1. ],
       [6.2, 3.4, 5.4, ..., 0. , 0. , 1. ],
       [5.9, 3. , 5.1, ..., 0. , 0. , 1. ]])
반응형

'[IT] > python.pandas' 카테고리의 다른 글

pandas.dt.(dayofweek,year,month,day,weekday,weekday_name)  (0) 2020.04.24
pandas.pivot_table  (0) 2020.04.24
pandas.drop_duplicates.reset_index  (0) 2020.04.24
pandas.string2code  (0) 2020.04.24
pandas.unstack(벡터로 펼치기(인덱스 두개))  (0) 2020.04.06
pandas.groupby  (0) 2020.04.06
pandas. 항목 추가  (0) 2020.04.06
pandas.drop_duplicates  (0) 2020.04.06
Comments