0

So I have a large numpy array with different data inside. I would like to extract a random array from this.

The dataset would look something like this:

[[ 0.00770334 -1.4224063  -2.4392433  ...  2.1296244   1.7076529
0.2145994 ]
[-0.9572602  -2.1521447  -2.7491045  ... -3.784852   -2.7787943
-1.727039  ]
[ 0.0106896  -1.8116834  -2.879299   ... -2.1569414  -0.56878865
0.49337843]
...
[-1.3776227  -3.2443993  -3.999786   ...  0.94508815  0.28934643
-1.6581179 ]
[-1.3281708  -2.0682802  -2.1291382  ... -0.1525341   0.0662522
0.54083973]
[ 0.7783776  -0.07668249 -0.9315217  ... -3.2098405  -2.137057
-1.103238  ]]

So I would like to get one of these random arrays out e.g.

[-1.3776227  -3.2443993  -3.999786   ...  0.94508815  0.28934643
-1.6581179 ]

2 Answers 2

1
data[np.random.choice(len(data), size=##Number of samples you need, replace=False)]
Sign up to request clarification or add additional context in comments.

Comments

0

try this:

random_index = np.random.randint(0, array.shape[0])
array[random_index]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.