[Numpy-discussion] Getting subarray

Bill Baxter wbaxter at gmail.com
Tue Apr 24 13:18:41 EDT 2007


Easy!
a[b==i]

--bb

On 4/24/07, Tommy Grav <tgrav at cfa.harvard.edu> wrote:
> I have two arrays:
>
> a = numpy.array([0,1,2,3,4,5,6,7,8,9])
> b = numpy.array([0,0,1,1,2,2,0,1,2,3])
>
> I would like to get the part of a that corresponds
> to where b is equal to i.
>
> For example:
>
> i = 0 => ([0,1,6])
> i = 1 => ([2,3,7])
>



More information about the NumPy-Discussion mailing list