I am looking at this question:
I have a similar problem, but two-dimensional Along with the array, where many coordinates and values are stored in the rows of the NumPy array. How can I do similar filtering like the above question?
My data looks like this:
& gt; & Gt; & Gt; Ashp (4269862, 5) & gt; & Gt; & Gt; A [0] array ([2.27011719e + 02, 0.00000000e + 00, 2.88134766e + 02, 2.00000000 E + 00, 7.69,80000E + 04], DTP = float 32) And this value corresponds to X, Y, Z and value1 and value2 I want to get the examples efficiently. All lines with X in 300--400, 200-2-250 in Y and 200 in 200-300
You can create a boolean mask that will be true when completing all your conditions:
idx = ((A [,, 0]> 300) & amp; (A [:, 0] <400) and (A [, 1]> 200) and (A) [, 1] & lt; 250) & amp; (A [, 2] & gt; 200) & amp; (A [,, 2] & lt; 300) Print an [idx] # This is your The array should be given to the lines where idx is true You can test it:
a = np.random.uniform (150, 500, ( 200, 5)) Volatile ('I') idx = ((A [, 0]> 300) & amp; (A [, 0] <400) & amp; (A [, 1 ]> 200) & amp; (A [, 1] & lt; 250) & amp; (A [, 2] & gt; 200) & amp; (A [, 2] & amp; Lt; 300) Print A [idx] # [[339-22921211 474] # [337 263 471 15 9 397] # [361 299 383 250 206] # [360 278 328] 1954 453] # [ 360 258 205 245 427] # [33 9 286 331 175 418]]
No comments:
Post a Comment