[Numpy-discussion] column_stack with len +/-1

Tim Hochberg tim.hochberg at cox.net
Tue May 9 13:20:03 EDT 2006


Ryan Krauss wrote:

> I am trying to column_stack a bunch of data vectors that I think
> should be the same length.  For whatever reason, my DAQ system doesn't
> always put out exactly the same length vector.  They should be 11,000
> elements long, but some are 11,000+/-1.
>
> How do I efficently drop one or two elements of the lists that are too
> long without making a bunch of accidental copies?
>
> What would
> newlist=[item[0:11000] for item in oldlist]
> do?


That should be fine in terms of copying; 'item[0:11000]' will be a view 
of item, not a copy and thus will be cheap in terms of memory and time. 
However, if the vectors are really 11000+/-1 in length, don't you need 
'items[:10999]' ?

-tim

>
> Ryan
>
>
> -------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job 
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache 
> Geronimo
> http://sel.as-us.falkag.net/sel?cmd=k&kid0709&bid&3057&dat1642
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
>






More information about the NumPy-Discussion mailing list