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

bro's coding

pandas.string2code 본문

[IT]/python.pandas

pandas.string2code

givemebro 2020. 4. 24. 09:40
반응형
# 꽃 이름에 따른 dictionary를 생성
label={i:iris.target_names[i] for i in range(3)}
label


# {0: 'setosa', 1: 'versicolor', 2: 'virginica'}

 

 

# target number에 따라 꽃 이름을 mapping
pd.Series(iris.target).map(label)

 

0         setosa
1         setosa
2         setosa
3         setosa
4         setosa
5         setosa
6         setosa
7         setosa
8         setosa
9         setosa
10        setosa
11        setosa
12        setosa
13        setosa
14        setosa
15        setosa
16        setosa
17        setosa
18        setosa
19        setosa
20        setosa
21        setosa
22        setosa
23        setosa
24        setosa
25        setosa
26        setosa
27        setosa
28        setosa
29        setosa
         ...    
120    virginica
121    virginica
122    virginica
123    virginica
124    virginica
125    virginica
126    virginica
127    virginica
128    virginica
129    virginica
130    virginica
131    virginica
132    virginica
133    virginica
134    virginica
135    virginica
136    virginica
137    virginica
138    virginica
139    virginica
140    virginica
141    virginica
142    virginica
143    virginica
144    virginica
145    virginica
146    virginica
147    virginica
148    virginica
149    virginica
Length: 150, dtype: object
반응형

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

pandas.groupby  (0) 2020.04.24
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.get_dummies.ont-hot-incoding  (0) 2020.04.24
pandas.unstack(벡터로 펼치기(인덱스 두개))  (0) 2020.04.06
pandas.groupby  (0) 2020.04.06
pandas. 항목 추가  (0) 2020.04.06
Comments