473,471 Members | 4,650 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

numpy and filtering (was: Fastest way to store ints and floats ondisk)

Attached there is an example program that only requires numpy. At the
end I have two numpy array:

rdims:

[[3 1 1]
[0 0 4]
[1 3 0]
[2 2 0]
[3 3 3]
[0 0 2]]
rmeas:

[[100000.0 254.0]
[40000.0 200.0]
[50000.0 185.0]
[5000.0 160.0]
[150000.0 260.0]
[20000.0 180.0]]
I would like to use numpy to create statistic, for example the mean
value of the prices:
>>rmeas[:,0] # Prices of cars
array([100000.0, 40000.0, 50000.0, 5000.0, 150000.0, 20000.0],
dtype=float96)
>>rmeas[:,0].mean() # Mean price
60833.3333333333333321

However, I only want to do this for 'color=yellow' or 'year=2003,
make=Ford' etc. I wonder if there a built-in numpy method that can
filter out rows using a set of values. E.g. create a view of the
original array or a new array that contains only the filtered rows. I
know how to do it from Python with iterators, but I wonder if there is a
better way to do it in numpy. (I'm new to numpy please forgive me if
this is a dumb question.)

Thanks,

Laszlo

Aug 8 '08 #1
0 720

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: 2mc | last post by:
I am finding out all kinds of ways to do things in NumPy through the many suggestions I have received. It's exciting. Thanks to all who have replied on my other threads. I'm still having...
2
by: robert | last post by:
in Gnuplot (Gnuplot.utils) the input array will be converted to a Numeric float array as shown below. When I insert a numpy array into Gnuplot like that below, numbers 7.44 are cast to 7.0 Why is...
5
by: robert | last post by:
Turning algs for old NumPy modules into numpy code I suffer from this: Upon further processing of returns of numpy calculations, lots of data in an apps object tree will become elementary numpy...
3
by: M.-A. Lemburg | last post by:
On 2008-08-07 20:41, Laszlo Nagy wrote: 1 It also very fast at dumping/loading lists, tuples, dictionaries, floats, etc. -- Marc-Andre Lemburg eGenix.com
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.