回答編集履歴
3
追記
test
CHANGED
@@ -68,7 +68,7 @@
|
|
68
68
|
|
69
69
|
|
70
70
|
|
71
|
-
d = [[*x, *y, *z] for x, y, z in zip(a, b, c)]
|
71
|
+
d = [[*x, *y, *z] for x, y, z in zip(a, b, c)] # [*x, *y, *z]じゃなくてx+y+zでいいかな・・・
|
72
72
|
|
73
73
|
print(d) # [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
|
74
74
|
|
2
修正
test
CHANGED
@@ -56,8 +56,6 @@
|
|
56
56
|
|
57
57
|
|
58
58
|
|
59
|
-
書き方としては、こんな感じでどうでしょうか。
|
60
|
-
|
61
59
|
|
62
60
|
|
63
61
|
```python
|
1
修正
test
CHANGED
@@ -1,38 +1,46 @@
|
|
1
|
-
この回答を投稿した時点で質問文には
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
> ```python
|
6
|
-
|
7
|
-
> a=[[1][2][3]]
|
8
|
-
|
9
|
-
> b=[[4][5][6]]
|
10
|
-
|
11
|
-
> c=[[7][8][9]]
|
12
|
-
|
13
|
-
>
|
14
|
-
|
15
|
-
> ```
|
16
|
-
|
17
|
-
> ```python
|
18
|
-
|
19
|
-
> d=[[1,4,7][2,5,8][3,6,9]]
|
20
|
-
|
21
|
-
> ```
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
1
|
+
numpy配列を水平方向に結合したい場合は、`numpy.hstack`が便利です。
|
26
2
|
|
27
3
|
|
28
4
|
|
29
5
|
```python
|
30
6
|
|
31
|
-
|
7
|
+
>>> import numpy as np
|
32
8
|
|
33
|
-
|
9
|
+
>>> data1 = np.array([[56], [102], [117], [142]])
|
34
10
|
|
11
|
+
>>> data2 = np.array([[55], [122], [176], [154]])
|
12
|
+
|
13
|
+
>>> data1
|
14
|
+
|
15
|
+
array([[ 56],
|
16
|
+
|
17
|
+
[102],
|
18
|
+
|
19
|
+
[117],
|
20
|
+
|
21
|
+
[142]])
|
22
|
+
|
23
|
+
>>> data2
|
24
|
+
|
25
|
+
array([[ 55],
|
26
|
+
|
27
|
+
[122],
|
28
|
+
|
29
|
+
[176],
|
30
|
+
|
31
|
+
[154]])
|
32
|
+
|
33
|
+
>>> data3 = np.hstack([data1, data2])
|
34
|
+
|
35
|
+
>>> data3
|
36
|
+
|
35
|
-
|
37
|
+
array([[ 56, 55],
|
38
|
+
|
39
|
+
[102, 122],
|
40
|
+
|
41
|
+
[117, 176],
|
42
|
+
|
43
|
+
[142, 154]])
|
36
44
|
|
37
45
|
|
38
46
|
|
@@ -40,21 +48,11 @@
|
|
40
48
|
|
41
49
|
|
42
50
|
|
43
|
-
```python
|
44
|
-
|
45
|
-
|
51
|
+
[numpy.hstack — NumPy v1.17 Manual](https://docs.scipy.org/doc/numpy/reference/generated/numpy.hstack.html)
|
46
|
-
|
47
|
-
```
|
48
52
|
|
49
53
|
|
50
54
|
|
51
|
-
だと仮定します。
|
52
|
-
|
53
|
-
|
55
|
+
#### 不要になった回答
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
---
|
58
56
|
|
59
57
|
|
60
58
|
|