質問編集履歴
2
コードを修正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -123,3 +123,91 @@
|
|
123
123
|
KeyError: "Passing list-likes to .loc or [] with any missing labels is no longer supported. The following labels were missing: Index(['Thai1.9', '2.0', '2.4', '2.7', '2.8',\n ...\n '5.3', '5.6', '6.3', '6.7', '7.0'],\n dtype='object', length=29). See https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike"
|
124
124
|
|
125
125
|
```
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
<
|
130
|
+
|
131
|
+
<カンマを追記したコード>
|
132
|
+
|
133
|
+
```ここに言語を入力
|
134
|
+
|
135
|
+
# 目的変数と説明変数に分割
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
columnList =['city_code','region_code','emailer_for_promotion','homepage_featured','TYPE_B','TYPE_C','Biryani','Desert','Extras',\
|
140
|
+
|
141
|
+
'Fish','Other Snacks','Pasta','Pizza','Rice Bowl','Salad','Sandwich','Seafood','Soup','Starters','Indian','Italian','Thai',\
|
142
|
+
|
143
|
+
'1.9','2.0','2.4','2.7','2.8','2.9','3.0','3.2','3.4','3.5','3.6','3.7','3.8','3.9','4.0','4.1','4.2','4.4','4.5',\
|
144
|
+
|
145
|
+
'4.6','4.7','4.8','5.0','5.1','5.3','5.6','6.3','6.7','7.0']
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
X = train_query.loc[:,columnList]
|
150
|
+
|
151
|
+
y = train_query.loc[:, ['num_rank']]
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
# モデル構築用データ、モデル検証用データに分割(80:20に分割)
|
156
|
+
|
157
|
+
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
print(X_train.shape)
|
162
|
+
|
163
|
+
print(X_test.shape)
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
print(y_train.shape)
|
168
|
+
|
169
|
+
print(y_test.shape)
|
170
|
+
|
171
|
+
```
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
<エラーコード>
|
176
|
+
|
177
|
+
```ここに言語を入力
|
178
|
+
|
179
|
+
KeyError Traceback (most recent call last)
|
180
|
+
|
181
|
+
<ipython-input-106-09c4fefa540e> in <module>()
|
182
|
+
|
183
|
+
26 columnList =['city_code','region_code','emailer_for_promotion','homepage_featured','TYPE_B','TYPE_C','Biryani','Desert','Extras', 'Fish','Other Snacks','Pasta','Pizza','Rice Bowl','Salad','Sandwich','Seafood','Soup','Starters','Indian','Italian','Thai', '1.9','2.0','2.4','2.7','2.8','2.9','3.0','3.2','3.4','3.5','3.6','3.7','3.8','3.9','4.0','4.1','4.2','4.4','4.5', '4.6','4.7','4.8','5.0','5.1',...
|
184
|
+
|
185
|
+
27
|
186
|
+
|
187
|
+
---> 28 X = train_query.loc[:,columnList]
|
188
|
+
|
189
|
+
29 y = train_query.loc[:, ['num_rank']]
|
190
|
+
|
191
|
+
30
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
6 frames
|
196
|
+
|
197
|
+
/usr/local/lib/python3.7/dist-packages/pandas/core/indexing.py in _validate_read_indexer(self, key, indexer, axis, raise_missing)
|
198
|
+
|
199
|
+
1314 with option_context("display.max_seq_items", 10, "display.width", 80):
|
200
|
+
|
201
|
+
1315 raise KeyError(
|
202
|
+
|
203
|
+
-> 1316 "Passing list-likes to .loc or [] with any missing labels "
|
204
|
+
|
205
|
+
1317 "is no longer supported. "
|
206
|
+
|
207
|
+
1318 f"The following labels were missing: {not_found}. "
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
KeyError: "Passing list-likes to .loc or [] with any missing labels is no longer supported. The following labels were missing: Index(['1.9', '2.0', '2.4', '2.7', '2.8',\n ...\n '5.3', '5.6', '6.3', '6.7', '7.0'],\n dtype='object', length=29). See https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike"
|
212
|
+
|
213
|
+
```
|
1
エラーのコードとエラー表記をコード状態で貼り付けました
test
CHANGED
File without changes
|
test
CHANGED
@@ -33,3 +33,93 @@
|
|
33
33
|
<データフレームの右側に、数字の変数が並んでいます。>
|
34
34
|
|
35
35
|
![イメージ説明](768e246099b84e7e4d1f5b2701726939.png)
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
<エラーのコードです>
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
```python
|
46
|
+
|
47
|
+
# 目的変数と説明変数に分割
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
columnList =['city_code','region_code','emailer_for_promotion','homepage_featured','TYPE_B','TYPE_C','Biryani','Desert','Extras',\
|
52
|
+
|
53
|
+
'Fish','Other Snacks','Pasta','Pizza','Rice Bowl','Salad','Sandwich','Seafood','Soup','Starters','Indian','Italian','Thai'\
|
54
|
+
|
55
|
+
'1.9','2.0','2.4','2.7','2.8','2.9','3.0','3.2','3.4','3.5','3.6','3.7','3.8','3.9','4.0','4.1','4.2','4.4','4.5',\
|
56
|
+
|
57
|
+
'4.6','4.7','4.8','5.0','5.1','5.3','5.6','6.3','6.7','7.0']
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
X = train_query.loc[:,columnList]
|
62
|
+
|
63
|
+
y = train_query.loc[:, ['num_rank']]
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
# モデル構築用データ、モデル検証用データに分割(80:20に分割)
|
68
|
+
|
69
|
+
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
print(X_train.shape)
|
74
|
+
|
75
|
+
print(X_test.shape)
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
print(y_train.shape)
|
80
|
+
|
81
|
+
print(y_test.shape)
|
82
|
+
|
83
|
+
```
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
<エラー表記です。>
|
88
|
+
|
89
|
+
```Python
|
90
|
+
|
91
|
+
KeyError Traceback (most recent call last)
|
92
|
+
|
93
|
+
<ipython-input-175-37e26af03518> in <module>()
|
94
|
+
|
95
|
+
18 columnList =['city_code','region_code','emailer_for_promotion','homepage_featured','TYPE_B','TYPE_C','Biryani','Desert','Extras', 'Fish','Other Snacks','Pasta','Pizza','Rice Bowl','Salad','Sandwich','Seafood','Soup','Starters','Indian','Italian','Thai' '1.9','2.0','2.4','2.7','2.8','2.9','3.0','3.2','3.4','3.5','3.6','3.7','3.8','3.9','4.0','4.1','4.2','4.4','4.5', '4.6','4.7','4.8','5.0','5.1','5.3'...
|
96
|
+
|
97
|
+
19
|
98
|
+
|
99
|
+
---> 20 X = train_query.loc[:,columnList]
|
100
|
+
|
101
|
+
21 y = train_query.loc[:, ['num_rank']]
|
102
|
+
|
103
|
+
22
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
6 frames
|
108
|
+
|
109
|
+
/usr/local/lib/python3.7/dist-packages/pandas/core/indexing.py in _validate_read_indexer(self, key, indexer, axis, raise_missing)
|
110
|
+
|
111
|
+
1314 with option_context("display.max_seq_items", 10, "display.width", 80):
|
112
|
+
|
113
|
+
1315 raise KeyError(
|
114
|
+
|
115
|
+
-> 1316 "Passing list-likes to .loc or [] with any missing labels "
|
116
|
+
|
117
|
+
1317 "is no longer supported. "
|
118
|
+
|
119
|
+
1318 f"The following labels were missing: {not_found}. "
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
KeyError: "Passing list-likes to .loc or [] with any missing labels is no longer supported. The following labels were missing: Index(['Thai1.9', '2.0', '2.4', '2.7', '2.8',\n ...\n '5.3', '5.6', '6.3', '6.7', '7.0'],\n dtype='object', length=29). See https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike"
|
124
|
+
|
125
|
+
```
|