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
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
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.
Hi,
So I've got a square floating point array that is about 1000 x 1000. I
need to subset this array as efficiently as possible based on an
ordered sublist of the list of rownames/colnames (they are the same,
this is a symmetric array).
e.g., if sublist is of length 500, and matches the