質問編集履歴

3

新しいエラーがでたため

2018/12/14 01:03

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -77,3 +77,13 @@
77
77
 
78
78
 
79
79
  ```
80
+
81
+ 以上のように修正しましたがリストの中身をそれぞれ表示したところ
82
+
83
+ [2.0, 4.0, 6.0, 8.0, 10.0]
84
+
85
+ [2.0, 4.0, 6.0, 8.0, 10.0, 2.0, 4.0, 6.0, 8.0, 10.0, 2.0, 4.0, 6.0, 8.0, 10.0]
86
+
87
+ [2.0, 4.0, 6.0, 8.0, 10.0]
88
+
89
+ のようになってしまいました

2

ミスがあったのを修正しました

2018/12/14 01:03

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -58,17 +58,17 @@
58
58
 
59
59
  for j in range(len(data)):
60
60
 
61
- if data[0,i] < 15:
61
+ if data[i,0] < 15:
62
62
 
63
- list01.append(data[1,j])
63
+ list01.append(data[j,1])
64
64
 
65
- if 15<= data[0,i] < 30:
65
+ if 15<= data[i,0] < 30:
66
66
 
67
- list02.append(data[1,j])
67
+ list02.append(data[j,1])
68
68
 
69
- if 30<= data[0,i] < 45:
69
+ if 30<= data[i,0] < 45:
70
70
 
71
- list03.append(data[1,j])
71
+ list03.append(data[j,1])
72
72
 
73
73
 
74
74
 
@@ -77,5 +77,3 @@
77
77
 
78
78
 
79
79
  ```
80
-
81
- list02.append(data[1,j])の行に index 2 is out of bounds for axis 1 with size 2というエラーが出てきました

1

指摘いただいた点を直しました

2018/12/14 00:59

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
 
26
26
 
27
- ### 作成したプログラム
27
+ ### 修正したプログラム
28
28
 
29
29
 
30
30
 
@@ -54,26 +54,28 @@
54
54
 
55
55
 
56
56
 
57
- for i,j in range(len(data))
57
+ for i in range(len(data)):
58
58
 
59
- if data[i,0] < 15:
59
+ for j in range(len(data)):
60
60
 
61
- list01.append(data[j,0])
61
+ if data[0,i] < 15:
62
62
 
63
- if 15<= data[i,0] < 30:
63
+ list01.append(data[1,j])
64
64
 
65
- list02.append(data[j,0])
65
+ if 15<= data[0,i] < 30:
66
66
 
67
- if 30<= data[i,0] < 45:
67
+ list02.append(data[1,j])
68
68
 
69
+ if 30<= data[0,i] < 45:
70
+
69
- list03.append(data[j,0])
71
+ list03.append(data[1,j])
72
+
73
+
74
+
75
+
70
76
 
71
77
 
72
78
 
73
79
  ```
74
80
 
75
- 以上のようなプログラムを作成しましたが、for i,j in range(len(data))の行で構文エラーがてしまいます。
81
+ list02.append(data[1,j])の行に index 2 is out of bounds for axis 1 with size 2というエラーがきま
76
-
77
- forの構文のどこにミスがあるのでしょうか、また、for文を使う以外にいい方法があれば教えていただきたいです。
78
-
79
- また、データを列ごとに扱うためにdata[i,0]のように表現してみたのですが、この表現の仕方で合っているのでしょうか?