Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Ted To
> You'd want to update your mask appropriately to get everything you > want to select, one criteria at a time e.g.: > mask = a[:,0] == 1 > mask &= a[:,1] == 1960 > > Alternatively: > mask = (a[:,0] == 1) & (a[:,1] == 1960) > but be careful with the parens, & and | are normally high-priority > bitw

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Brett Olsen
On Mon, Jan 30, 2012 at 11:31 AM, Ted To wrote: > On 01/30/2012 12:13 PM, Brett Olsen wrote: >> On Mon, Jan 30, 2012 at 10:57 AM, Ted To wrote: >>> Sure thing.  To keep it simple suppose I have just a two dimensional >>> array (time,output): >>> [(1,2),(2,3),(3,4)] >>> I would like to look at all

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Zachary Pincus
> Thanks! That works great if I only want to search over one index but I > can't quite figure out what to do with more than a single index. So > suppose I have a labeled, multidimensional array with labels 'month', > 'year' and 'quantity'. a[['month','year']] gives me an array of indices > but "

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Ted To
On 01/30/2012 12:13 PM, Brett Olsen wrote: > On Mon, Jan 30, 2012 at 10:57 AM, Ted To wrote: >> Sure thing. To keep it simple suppose I have just a two dimensional >> array (time,output): >> [(1,2),(2,3),(3,4)] >> I would like to look at all values of output for which, for example time==2. >> >>

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Brett Olsen
On Mon, Jan 30, 2012 at 10:57 AM, Ted To wrote: > Sure thing.  To keep it simple suppose I have just a two dimensional > array (time,output): > [(1,2),(2,3),(3,4)] > I would like to look at all values of output for which, for example time==2. > > My actual application has a six dimensional array a

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Ted To
Sure thing. To keep it simple suppose I have just a two dimensional array (time,output): [(1,2),(2,3),(3,4)] I would like to look at all values of output for which, for example time==2. My actual application has a six dimensional array and I'd like to look at the contents using one or more of the

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Zachary Pincus
Ted, can you clarify what you're asking for? Maybe give a trivial example of an array and the desired output? I'm pretty sure this is a slicing question though: > If I have a three dimensional array a=(x,y,z), can I look at the values of z > given particular values for x and y? Given that elemen

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Chao YUE
he is not asking for slicing. he is asking for how to index array by element value but not element index. 2012/1/30 Zachary Pincus > a[x,y,:] > > Read the slicing part of the tutorial: > http://www.scipy.org/Tentative_NumPy_Tutorial > (section 1.6) > > And the documentation: > http://docs.scipy.

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Zachary Pincus
a[x,y,:] Read the slicing part of the tutorial: http://www.scipy.org/Tentative_NumPy_Tutorial (section 1.6) And the documentation: http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html On Jan 30, 2012, at 10:25 AM, Ted To wrote: > Hi, > > Is there some straightforward way to access

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Malcolm Reynolds
On Mon, Jan 30, 2012 at 3:25 PM, Ted To wrote: > Is there some straightforward way to access an array by values across a > subset of its dimensions?  For example, if I have a three dimensional > array a=(x,y,z), can I look at the values of z given particular values > for x and y? a[x, y, :] shoul

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Chao YUE
I am afraid you have to write index inquire function by yourself. I did like this. chao 2012/1/30 Ted To > Hi, > > Is there some straightforward way to access an array by values across a > subset of its dimensions? For example, if I have a three dimensional > array a=(x,y,z), can I look at the

[Numpy-discussion] Addressing arrays

2012-01-30 Thread Ted To
Hi, Is there some straightforward way to access an array by values across a subset of its dimensions? For example, if I have a three dimensional array a=(x,y,z), can I look at the values of z given particular values for x and y? Thanks, Ted ___ NumPy-D