I have a matrix list of 100x3 as shown below.
There are two things I would like to do for this matrix:
·I would like to randomly extract two lines at any number of times (e.g., 3 times).
ex)[[a1, a2, a3],
] [b1, b2, b3]
·I want to change the extracted two rows to become one row and create a matrix of the number of attempts x the set of rows taken out.
[[a1, a2, a3, b1, b2, b3],
[c1, c2, c3, d1, d2, d3],
[e1, e2, e2, f1, f2, f3]
The first 100x3 matrix treats it as a block of values for one line, or three values.
First of all, the appropriate matrix
When there was
a.shape takes the row size of
a and creates an index random number with
replace=False is the option to have no duplication.You can now extract the line in the form
I wrote it sequentially with reference to the person who answered.
If you change X and Y, I think you can create them with some free values.
© 2022 OneMinuteCode. All rights reserved.