Re: [Numpy-discussion] an indexing question

2014-01-08 Thread Jaime Fernández del Río
On Wed, Jan 8, 2014 at 11:12 AM, Neal Becker wrote: > I have a 1d vector d. I want compute the means of subsets of this vector. > The subsets are selected by looking at another vector s or same shape as d. > > This can be done as: > > [np.mean (d[s == i]) for i in range (size)] > > But I think t

[Numpy-discussion] an indexing question

2014-01-08 Thread Neal Becker
I have a 1d vector d. I want compute the means of subsets of this vector. The subsets are selected by looking at another vector s or same shape as d. This can be done as: [np.mean (d[s == i]) for i in range (size)] But I think this could be done directly with numpy addressing, without resorting