質問編集履歴
2
内容の明確化
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,9 +12,9 @@
|
|
12
12
|
|
13
13
|
### 参考.2
|
14
14
|
|
15
|
-
横
|
15
|
+
横4列,縦100列のデータセットがあります。
|
16
|
-
|
16
|
+
|
17
|
-
列["X"]と["Y"]の最小値から10行刻みで、列["X coordinate"]と["Y coordinate"]に数字を割り振っていきたいと思っています。
|
17
|
+
列["X"]と["Y"]の最小値から10行刻みで、列["X coordinate"]と["Y coordinate"]を追加した後に数字を割り振っていきたいと思っています。
|
18
18
|
|
19
19
|
(例:データ1番目(行)から10番目(行)までは "1",11~20までは"2" 20~30までは3....)
|
20
20
|
|
@@ -34,12 +34,18 @@
|
|
34
34
|
|
35
35
|
```
|
36
36
|
|
37
|
-
#[
|
37
|
+
#[ラベル追加前のラベル]<参考.2>
|
38
38
|
|
39
39
|
|Label|X|Y|Sumple|Bean Number|X coordinate|Y coordinate|
|
40
40
|
|
41
41
|
|:--|:--: |--:|
|
42
42
|
|
43
|
+
#[(ラベル追加後)処理前のデータセット]
|
44
|
+
|
45
|
+
|Label|X|Y|Sumple|Bean Number|X coordinate|Y coordinate|
|
46
|
+
|
47
|
+
|:--|:--: |--:|
|
48
|
+
|
43
49
|
|img061c.jpg|886|3400|くるみ豆|B2|0|0|
|
44
50
|
|
45
51
|
|img061c.jpg|899|1730|くるみ豆|B2|0|0|
|
@@ -138,63 +144,55 @@
|
|
138
144
|
|
139
145
|
### 発生している問題・エラーメッセージ
|
140
146
|
|
147
|
+
|
148
|
+
|
149
|
+
### 該当のソースコード2019/04/22 16:00訂正
|
150
|
+
|
151
|
+
```Python3
|
152
|
+
|
153
|
+
import os
|
154
|
+
|
155
|
+
import pandas as pd
|
156
|
+
|
157
|
+
import numpy as np
|
158
|
+
|
159
|
+
import glob
|
160
|
+
|
161
|
+
os.chdir("C://Users//For Programming//Documents//Python Scripts2")
|
162
|
+
|
163
|
+
list = []
|
164
|
+
|
165
|
+
filelist = os.listdir()
|
166
|
+
|
167
|
+
for file in filelist:
|
168
|
+
|
169
|
+
df = pd.read_csv(file,encoding="shift-jis")
|
170
|
+
|
171
|
+
for g in df:
|
172
|
+
|
173
|
+
df['X coordinate'] = int()
|
174
|
+
|
175
|
+
df['Y coordinate'] = int()
|
176
|
+
|
177
|
+
df['X coordinate'] = (((df['X'].rank(method='first') + 9) //10)).astype(int)
|
178
|
+
|
179
|
+
df['Y coordinate'] = (((df['Y'].rank(method='first') + 9) //10)).astype(int)
|
180
|
+
|
181
|
+
df2 = list.append(pd.read_csv(g,encoding="shift-jis")) #ここから上手くlist.apendを使えない。
|
182
|
+
|
183
|
+
for h in df2:
|
184
|
+
|
185
|
+
df3 = pd.concat(list)
|
186
|
+
|
187
|
+
df3.to_csv("TOTAL.csv", encoding='shift_jis')
|
188
|
+
|
141
189
|
```
|
142
190
|
|
143
|
-
FileNotFoundError: [Errno 2] File b'img061cNew.csv' does not exist: b'img061cNew.csv'
|
144
|
-
|
145
|
-
※→(この'img061cNew.csv'というのはos.chdirdで指定した先にあるファイルの一つです)
|
146
|
-
|
147
|
-
```
|
148
|
-
|
149
|
-
### 該当のソースコード
|
150
|
-
|
151
|
-
```Python3
|
152
|
-
|
153
|
-
import os
|
154
|
-
|
155
|
-
import pandas as pd
|
156
|
-
|
157
|
-
import glob
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
os.chdir("C://Users//For Programming//Documents//Python Scripts2")
|
162
|
-
|
163
|
-
|
191
|
+
### 試したこと、実装する上で障害になっている事。2019/04/22 18:00訂正
|
164
|
-
|
165
|
-
|
192
|
+
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
def Decision_coordinates():
|
170
|
-
|
171
|
-
df1 = pd.read_csv(csv_files, encoding="shift-jis")
|
172
|
-
|
173
|
-
|
193
|
+
(恐らくですが)フォルダー内にあるファイルを全て読み込み、特定の操作をかける所までは
|
174
|
-
|
175
|
-
|
194
|
+
|
176
|
-
|
177
|
-
df1['X coordinate'] = (((df1['X'].rank(method='first') + 9) // 10)).astype(int)
|
178
|
-
|
179
|
-
df1['Y coordinate'] = (((df1['Y'].rank(method='first') + 9) // 10)).astype(int)
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
for f in Decision_coordinates:
|
186
|
-
|
187
|
-
list.append(pd.read_table(f, encoding="shift-jis"))
|
188
|
-
|
189
|
-
df = pd.concat(lst)
|
190
|
-
|
191
|
-
df.to_csv("TOTAL.csv", encoding='shift_jis')
|
192
|
-
|
193
|
-
```
|
194
|
-
|
195
|
-
### 試したこと
|
196
|
-
|
197
|
-
|
195
|
+
上手くいってると思うのですが、特定の操作をかけた後に結果のDataFrame、リストに入れる?部分が上手くいってないです。(「for g in df:」の最終行の部分)
|
198
196
|
|
199
197
|
### 補足情報(FW/ツールのバージョンなど)
|
200
198
|
|
1
内容の明確化
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,7 +12,13 @@
|
|
12
12
|
|
13
13
|
### 参考.2
|
14
14
|
|
15
|
+
横6列,縦100列のデータセットがあります。
|
16
|
+
|
17
|
+
列["X"]と["Y"]の最小値から10行刻みで、列["X coordinate"]と["Y coordinate"]に数字を割り振っていきたいと思っています。
|
18
|
+
|
15
|
-
|
19
|
+
(例:データ1番目(行)から10番目(行)までは "1",11~20までは"2" 20~30までは3....)
|
20
|
+
|
21
|
+
(下記の「完成させたいデータセット」のようなイメージです)
|
16
22
|
|
17
23
|
```Python3
|
18
24
|
|
@@ -28,7 +34,7 @@
|
|
28
34
|
|
29
35
|
```
|
30
36
|
|
31
|
-
[処理前のデータセット]
|
37
|
+
#[処理前のデータセット]<参考.2>
|
32
38
|
|
33
39
|
|Label|X|Y|Sumple|Bean Number|X coordinate|Y coordinate|
|
34
40
|
|
@@ -80,7 +86,7 @@
|
|
80
86
|
|
81
87
|
|
82
88
|
|
83
|
-
[処理後のデータセット]
|
89
|
+
#[処理後のデータセット]<参考.2>
|
84
90
|
|
85
91
|
|Label|X|Y|Sumple|Bean Number|X coordinate|Y coordinate|
|
86
92
|
|
@@ -152,7 +158,7 @@
|
|
152
158
|
|
153
159
|
|
154
160
|
|
155
|
-
os.chdir("C://Users
|
161
|
+
os.chdir("C://Users//For Programming//Documents//Python Scripts2")
|
156
162
|
|
157
163
|
csv_files = glob.glob('*.csv')
|
158
164
|
|
@@ -198,7 +204,7 @@
|
|
198
204
|
|
199
205
|
Jupyter notebook
|
200
206
|
|
201
|
-
|
207
|
+
Pycharm
|
202
208
|
|
203
209
|
お忙しいとは思いますが、よろしくお願いいたします。
|
204
210
|
|