Re: where function

2007-03-18 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > On Mar 18, 10:48 pm, [EMAIL PROTECTED] wrote: >> [...fine solutions to the problem as asked...] > Thank you both, a little more cumbersome than I expected, but it does > the job! Thanks! The obvious simple near-equivalent is: data = range(33,99) print data.ind

Re: where function

2007-03-18 Thread Steven Bethard
[EMAIL PROTECTED] wrote: > Is there a function in Python analogous to the "where" function in > IDL? > > x=[0,1,2,3,4,2,8,9] > print where(x=2) > > output: > [2,5] If you're doing a lot of this kind of thing, you probably want to use numpy:: >&

Re: where function

2007-03-18 Thread Shane Geiger
PROTECTED] wrote: On Mar 18, 10:48 pm, [EMAIL PROTECTED] wrote: vorticitywo: Is there a function in Python analogous to the "where" function in IDL? Python gives very elastic syntax, you can simply do: data = [0,1,2,3,4,2,8,9] print [pos for pos, el in enumerate(data

Re: where function

2007-03-18 Thread vorticitywolfe
On Mar 18, 10:48 pm, [EMAIL PROTECTED] wrote: > vorticitywo: > > > Is there a function in Python analogous to the "where" function in > > IDL? > > Python gives very elastic syntax, you can simply do: > > data = [0,1,2,3,4,2,8,9] > print [pos for p

Re: where function

2007-03-18 Thread drochom
On 18 Mar, 15:19, [EMAIL PROTECTED] wrote: > Is there a function in Python analogous to the "where" function in > IDL? > > x=[0,1,2,3,4,2,8,9] > print where(x=2) > > output: > [2,5] You can try this: print filter( lambda x: a[x]==2, range(len(a))) However it&#x

Re: where function

2007-03-18 Thread bearophileHUGS
vorticitywo: > Is there a function in Python analogous to the "where" function in > IDL? Python gives very elastic syntax, you can simply do: data = [0,1,2,3,4,2,8,9] print [pos for pos, el in enumerate(data) if el==2] Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

where function

2007-03-18 Thread vorticitywolfe
Is there a function in Python analogous to the "where" function in IDL? x=[0,1,2,3,4,2,8,9] print where(x=2) output: [2,5] -- http://mail.python.org/mailman/listinfo/python-list

Re: Numeric: 'where' function conditions

2004-11-30 Thread Jorl Shefner
In article <[EMAIL PROTECTED]>, Robert Kern <[EMAIL PROTECTED]> wrote: > > Right. "3 < data" creates an array of 0s and 1s where the condition is > false and true, respectively. You don't need where() at all. > > Try > > mask = logical_and(3 < data, data <= 7) Great. That's exactly what I n

Re: Numeric: 'where' function conditions

2004-11-29 Thread Robert Kern
Jorl Shefner wrote: Could anyone tell me the efficient way to do this? Extracting values from an array for a single condition (say all values greater than 'x') using 'where' and 'compress' is simple enough. from Numeric import arange,where,compress data= arange(10) data= [0, 1, 2, 3, 4, 5,

Numeric: 'where' function conditions

2004-11-29 Thread Jorl Shefner
Could anyone tell me the efficient way to do this? Extracting values from an array for a single condition (say all values greater than 'x') using 'where' and 'compress' is simple enough. >>> from Numeric import arange,where,compress >>> data= arange(10) >>> data= [0, 1, 2, 3, 4, 5, 6, 7, 8,