回答編集履歴
2
追記
test
CHANGED
@@ -1,10 +1,18 @@
|
|
1
|
-
|
1
|
+
【追記】
|
2
|
-
|
3
|
-
|
4
2
|
|
5
3
|
```Python
|
6
4
|
|
5
|
+
n = np.array(range(15)).reshape(3,5)
|
6
|
+
|
7
|
+
#array([[ 0, 1, 2, 3, 4],
|
8
|
+
|
9
|
+
# [ 5, 6, 7, 8, 9],
|
10
|
+
|
11
|
+
# [10, 11, 12, 13, 14]])
|
12
|
+
|
7
|
-
random.sample(
|
13
|
+
print([random.sample(n.tolist(),2)])
|
14
|
+
|
15
|
+
#[[[0, 1, 2, 3, 4], [10, 11, 12, 13, 14]]]
|
8
16
|
|
9
17
|
```
|
10
18
|
|
@@ -35,3 +43,15 @@
|
|
35
43
|
#[[4, 0, 1], [5, 7, 9], [13, 11, 14]]
|
36
44
|
|
37
45
|
```
|
46
|
+
|
47
|
+
------
|
48
|
+
|
49
|
+
下記で出来ませんか?
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
```Python
|
54
|
+
|
55
|
+
random.sample(data.ravel().tolist(),points)
|
56
|
+
|
57
|
+
```
|
1
追記
test
CHANGED
@@ -7,3 +7,31 @@
|
|
7
7
|
random.sample(data.ravel().tolist(),points)
|
8
8
|
|
9
9
|
```
|
10
|
+
|
11
|
+
------
|
12
|
+
|
13
|
+
【追記】こういうことでしょうか? ※下記は簡単な例です。
|
14
|
+
|
15
|
+
```Python
|
16
|
+
|
17
|
+
import numpy as np
|
18
|
+
|
19
|
+
import random
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
n = np.array(range(15)).reshape(3,5)
|
24
|
+
|
25
|
+
#array([[ 0, 1, 2, 3, 4],
|
26
|
+
|
27
|
+
# [ 5, 6, 7, 8, 9],
|
28
|
+
|
29
|
+
# [10, 11, 12, 13, 14]])
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
n2 = [random.sample(i.tolist(), 3) for i in n]
|
34
|
+
|
35
|
+
#[[4, 0, 1], [5, 7, 9], [13, 11, 14]]
|
36
|
+
|
37
|
+
```
|