[SciPy-User] creating a view of an array

Martin van Leeuwen vanleeuwen.martin at gmail.com
Sat Jul 30 17:48:48 EDT 2011


Hi Mathieu,

You can index using a tuple too, like:

a[:,(0,2)]

That way you can index into any columns.

Martin

2011/7/30 mathieu lacage <mathieu.lacage at alcmeon.com>:
> hi,
>
> Let's say I have a big large array:
>
> a = numpy.empty((10000*1000,10))
>
> and I want to create a view of that array to be able to process a subset of
> its data without making a copy.
>
> One column:
> b = a[:,1]
>
> Two adjacent columns:
> b = a[:,1:2]
>
> Can I do the same (no memory allocation) for two columns that are not
> adjacent ? i.e. if I want to create an array that is a view for the 1st and
> 3rd columns.
>
>
> Mathieu
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>



More information about the SciPy-User mailing list