[Numpy-discussion] On responding to dubious ideas (was: Re: Advanced indexing: "fancy" vs. orthogonal)
Jaime Fernández del Río
jaime.frio at gmail.com
Thu Apr 9 23:37:22 EDT 2015
On Thu, Apr 9, 2015 at 8:26 PM, Alexander Belopolsky <ndarray at mac.com>
wrote:
>
> On Thu, Apr 9, 2015 at 8:41 PM, Derek Homeier <
> derek at astro.physik.uni-goettingen.de> wrote:
>
>> > but if I try to do both, I get the diagonal instead
>> >
>> > >>> a[[1,2],[1,2]]
>> > array([22, 33])
>> >
>> a[1:3,1:3]?
>>
>> Can’t be generalised to arbitrary selections of rows,columns, though
>> (e.g. a[1::2,::2] still works…)
>>
>
> I am interested in the arbitrary selection of rows and columns given by
> indices or by boolean selectors.
>
This is what you are looking for:
a[np.ix_([1, 2], [1, 2])]
Jaime
--
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes
de dominación mundial.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150409/ef375cd0/attachment.html>
More information about the NumPy-Discussion
mailing list