On 2009-02-17 14:36, Nick Matzke wrote:
Looks like "compress" is the right numpy function, but it took forever
for me to find it...
x = array([[1,2,3], [4,5,6], [7,8,9]], dtype=float)
compress([1,2], x, axis=1)
result:
array([[ 1., 2.],
[ 4., 5.],
[ 7., 8.]])
No, that's actually not correct.
Looks like "compress" is the right numpy function, but it took forever
for me to find it...
x = array([[1,2,3], [4,5,6], [7,8,9]], dtype=float)
compress([1,2], x, axis=1)
result:
array([[ 1., 2.],
[ 4., 5.],
[ 7., 8.]])
Gary Herron wrote:
Nick Matzke wrote:
Hi,
So I've g
Nick Matzke:
> I have to do this hundreds of times, so speed would be useful.
Try to create a 2D array with NumPy, and then slice it. Note that
slicing syntax has a "stride" too.
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list