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,: - 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]]
1 3002 Banfa 9,065
Recognized Expert Moderator Expert
Use a filter - computed = list(filter(lambda x: math.fabs(x[2]) < 100, input))
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mattyw |
last post by:
Hi
I have a sqlcommand that returns all the rows in a column and then pass
that to a datareader.
I am new to VS.Net and so far I can only return the first row in the
first column using
...
|
by: Billy |
last post by:
Change DataGrid EditControl On Data Value
Hi,
I have a datagrid, and on editing, I want to change the control in the third
colunm based on the value of the first column.
The value in the...
|
by: tasmontique |
last post by:
I have an access table that outputs to excel using a query . However what I am trying to do is under the arrival date column specify a criteria based on the Datepart function that only displays...
|
by: Andy B |
last post by:
I need to take an existing GridView that connects to a database and gets
rows from a table and force it to show x rows in the insert mode. This is
what should happen:
1. There is a TextBox in...
|
by: ravir81 |
last post by:
Hi,
I am currently working on excel validation using Perl. I am new to Excel validation but not for Perl. I have a question regarding one of the validation. Could anyone please tell me how to get...
| |
by: Vinda |
last post by:
Hi Bytes,
Using a previous question as a base Access 2000 Inserting multiple rows based on a date range.
I also wanted to insert multiple rows into a table according to a date range supplied by a...
|
by: patrick keady |
last post by:
This feels simple. But not enough coffee I suppose. Cant get it to work.
I have about ten worksheets in a workbook. The first worksheet is where I want ROWS returned to from the other 9...
|
by: Fspinelli |
last post by:
I have a table with various information (company name, address, etc.) plus five check boxes. One or more of those check boxes may be ticked as it relays a type of status to the end user.
I have a...
|
by: baba |
last post by:
Hi,
I want the entire row color to change based on a column value in a report.
Foe example: Select Name,Age,Salary from table 1 -cretes 3 rows.
Name Age Salary
A 15 1000
B ...
|
by: SNFBS |
last post by:
how to get the table name based on column name?
I got column name but i dont know the location of that column, in which table.since i got about >300 tables in database
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |