Re: substituting list comprehensions for map()

2009-11-02 Thread Neil Crighton
Steven D'Aprano REMOVE.THIS.cybersource.com.au> writes: > > > > operandlist1=[1,2,3,4,5] > > operandlist2=[5,4,3,2,1] > > > > and resultlist will become [6,6,6,6,6]. Using map(), I can do: > > > > map(lambda op1,op2: op1 + op2, operandlist1, operandlist2) > > If the two lists are very large,

Re: finding most common elements between thousands of multiple arrays.

2009-07-04 Thread Neil Crighton
You can join all your arrays into a single big array with concatenate. >>> import numpy as np >>> a = np.concatenate(array_of_arrays) Then count the number of occurrances of each unique element using this trick with searchsorted. This should be pretty fast. >>> a.sort() >>> unique_a = np.unique(

Re: Regarding sort()

2009-05-25 Thread Neil Crighton
Dhananjay gmail.com> writes: > I want to sort the data on the basis of 3rd column first and latter want to > sort the sorted data (in first step) on the basis of 6th column.I tried > sort() function but could not get the way how to use it.I am new to > programming, please tell me how can I sor

Re: numpy.where

2009-04-09 Thread Neil Crighton
Carl Banks gmail.com> writes: > > >>> condition = (min_time <= time) & (time <= max_time) > > >>> new_time = time[condition] > > >>> new_energy = energy[condition] > > Won't work: condition is an array of ones and zeros, but you need to > index the arrays with indices. So, add a call to nonzero

Re: numpy.where

2009-04-09 Thread Neil Crighton
heidi taynton mac.com> writes: > > Hi, > > I'm fairly new to programming and am having a probably cutting my arrays. I have two different 1d arrays, one > of time, and the second energy.I want to cut both arrays of time min<=time<=max . I've created a 2d array > with [time,energy] an

Problem with zipfile and newlines

2008-03-10 Thread Neil Crighton
I'm using the zipfile library to read a zip file in Windows, and it seems to be adding too many newlines to extracted files. I've found that for extracted text-encoded files, removing all instances of '\r' in the extracted file seems to fix the problem, but I can't find an easy solution for binary