Aug-06-2020, 04:22 PM
Hi Everyone,
Here is an interesting problem I am trying to solve.
I have a (Nx4) array and want to extract those rows which have their third column's element in certain range. Are there existing capabilities in NumPy? Below is a simple example.
PS: I know how for loops can be used by comparing each element of col. 3; and saving the rows that meet the condition. But I want to use NumPy here (like slicing etc., that is promisingly fast). In reality, the arrays I use are large and implementing additional loops will sacrifice comp. times.
For example,:
Here is an interesting problem I am trying to solve.
I have a (Nx4) array and want to extract those rows which have their third column's element in certain range. Are there existing capabilities in NumPy? Below is a simple example.
PS: I know how for loops can be used by comparing each element of col. 3; and saving the rows that meet the condition. But I want to use NumPy here (like slicing etc., that is promisingly fast). In reality, the arrays I use are large and implementing additional loops will sacrifice comp. times.
For example,:
input = [[1,2,-97,4], [5,6,93,8], [9,10,-105,12], [11,12,105,14]] output = [[1,2,-97,4], # desired output: rows in which column third's element is greater than -100 and less than 100 [5,6,93,8]]