質問編集履歴

2

import 文の変更

2019/08/16 06:26

投稿

chgrios
chgrios

スコア70

test CHANGED
File without changes
test CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  ```python
6
6
 
7
- import andas as pd
7
+ import pandas as pd
8
8
 
9
9
  import seaborn as sns
10
10
 
11
- from sklearn import KMeans
11
+ from sklearn.cluster import KMeans
12
12
 
13
13
 
14
14
 

1

エラーメッセージを追加しました。モジュールのインポート宣言を追加しました。

2019/08/16 06:26

投稿

chgrios
chgrios

スコア70

test CHANGED
File without changes
test CHANGED
@@ -4,6 +4,12 @@
4
4
 
5
5
  ```python
6
6
 
7
+ import andas as pd
8
+
9
+ import seaborn as sns
10
+
11
+ from sklearn import KMeans
12
+
7
13
 
8
14
 
9
15
  features = np.array([
@@ -58,7 +64,137 @@
58
64
 
59
65
  ```
60
66
 
61
-
67
+ ```ここに言語を入力
68
+
69
+ ---------------------------------------------------------------------------
70
+
71
+ KeyError Traceback (most recent call last)
72
+
73
+ /usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
74
+
75
+ 2889 try:
76
+
77
+ -> 2890 return self._engine.get_loc(key)
78
+
79
+ 2891 except KeyError:
80
+
81
+
82
+
83
+ pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
84
+
85
+
86
+
87
+ pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
88
+
89
+
90
+
91
+ pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
92
+
93
+
94
+
95
+ pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
96
+
97
+
98
+
99
+ KeyError: 'label'
100
+
101
+
102
+
103
+ During handling of the above exception, another exception occurred:
104
+
105
+
106
+
107
+ KeyError Traceback (most recent call last)
108
+
109
+ <ipython-input-134-0c6750a0a143> in <module>
110
+
111
+ 56 # colors = [color_codes[x] for x in labels]
112
+
113
+ 57 # plotting.scatter_matrix(df)
114
+
115
+ ---> 58 sns.pairplot(df_concat.iloc[:,:3], hue='label',diag_kind='kde')
116
+
117
+ 59
118
+
119
+ 60 #put labels aside
120
+
121
+
122
+
123
+ /usr/local/lib/python3.6/dist-packages/seaborn/axisgrid.py in pairplot(data, hue, hue_order, palette, vars, x_vars, y_vars, kind, diag_kind, markers, height, aspect, dropna, plot_kws, diag_kws, grid_kws, size)
124
+
125
+ 2082 hue_order=hue_order, palette=palette,
126
+
127
+ 2083 diag_sharey=diag_sharey,
128
+
129
+ -> 2084 height=height, aspect=aspect, dropna=dropna, **grid_kws)
130
+
131
+ 2085
132
+
133
+ 2086 # Add the markers here as PairGrid has figured out how many levels of the
134
+
135
+
136
+
137
+ /usr/local/lib/python3.6/dist-packages/seaborn/axisgrid.py in __init__(self, data, hue, hue_order, palette, hue_kws, vars, x_vars, y_vars, diag_sharey, height, aspect, despine, dropna, size)
138
+
139
+ 1288 index=data.index)
140
+
141
+ 1289 else:
142
+
143
+ -> 1290 hue_names = utils.categorical_order(data[hue], hue_order)
144
+
145
+ 1291 if dropna:
146
+
147
+ 1292 # Filter NA from the list of unique hue names
148
+
149
+
150
+
151
+ /usr/local/lib/python3.6/dist-packages/pandas/core/frame.py in __getitem__(self, key)
152
+
153
+ 2973 if self.columns.nlevels > 1:
154
+
155
+ 2974 return self._getitem_multilevel(key)
156
+
157
+ -> 2975 indexer = self.columns.get_loc(key)
158
+
159
+ 2976 if is_integer(indexer):
160
+
161
+ 2977 indexer = [indexer]
162
+
163
+
164
+
165
+ /usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
166
+
167
+ 2890 return self._engine.get_loc(key)
168
+
169
+ 2891 except KeyError:
170
+
171
+ -> 2892 return self._engine.get_loc(self._maybe_cast_indexer(key))
172
+
173
+ 2893 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
174
+
175
+ 2894 if indexer.ndim > 1 or indexer.size > 1:
176
+
177
+
178
+
179
+ pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
180
+
181
+
182
+
183
+ pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
184
+
185
+
186
+
187
+ pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
188
+
189
+
190
+
191
+ pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
192
+
193
+
194
+
195
+ KeyError: 'label'
196
+
197
+ ```
62
198
 
63
199
  ここでhue='label'にするとエラーがでてしまいます。labelのデータタイプはオブジェクトのはずなのですが、、、
64
200