回答編集履歴
3
追記
answer
CHANGED
@@ -16,4 +16,7 @@
|
|
16
16
|
tate [16 17 7]
|
17
17
|
yoko [ 7 10 9 14]
|
18
18
|
"""
|
19
|
-
```
|
19
|
+
```
|
20
|
+
|
21
|
+
numpyは本当に痒い所に手が届きます。
|
22
|
+
『numpy 〇〇』ってまず検索してみると良いですよ。
|
2
修正
answer
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
```Python
|
2
2
|
import numpy as np
|
3
3
|
|
4
|
-
|
4
|
+
my_array = np.array([[1, 2, 4],
|
5
|
-
|
5
|
+
[4, 5, 1],
|
6
|
-
|
6
|
+
[5, 3, 1],
|
7
|
-
|
7
|
+
[6, 7, 1]]
|
8
8
|
)
|
9
|
-
tate = np.sum(
|
9
|
+
tate = np.sum(my_array, axis=0)
|
10
|
-
yoko = np.sum(
|
10
|
+
yoko = np.sum(my_array, axis=1)
|
11
11
|
|
12
12
|
print('tate', tate)
|
13
13
|
print('yoko', yoko)
|
1
成形
answer
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
```Python
|
2
2
|
import numpy as np
|
3
3
|
|
4
|
-
array = np.array([[1, 2, 4],
|
4
|
+
array = np.array([[1, 2, 4],
|
5
|
+
[4, 5, 1],
|
6
|
+
[5, 3, 1],
|
7
|
+
[6, 7, 1]]
|
8
|
+
)
|
5
9
|
tate = np.sum(array, axis=0)
|
6
10
|
yoko = np.sum(array, axis=1)
|
7
11
|
|
8
|
-
print(tate)
|
12
|
+
print('tate', tate)
|
9
|
-
print(yoko)
|
13
|
+
print('yoko', yoko)
|
10
14
|
|
11
15
|
"""出力
|
12
|
-
[16 17 7]
|
16
|
+
tate [16 17 7]
|
13
|
-
[ 7 10 9 14]
|
17
|
+
yoko [ 7 10 9 14]
|
14
18
|
"""
|
15
19
|
```
|