[Numpy-discussion] invert bincounts?

Jaime Fernández del Río jaime.frio at gmail.com
Thu Feb 27 22:01:41 EST 2014


On Thu, Feb 27, 2014 at 6:11 PM, Alan G Isaac <alan.isaac at gmail.com> wrote:

> I have a bincount array `cts`.
> I'd like to produce any one array `a` such that `cts==np.bincounts(a)`.
> Easy to do in a loop, but does NumPy offer a better (i.e., faster) way?
>

>>> cts = np.bincount([1,1,2,3,4,4,6])
>>> np.repeat(np.arange(len(cts)), cts)
array([1, 1, 2, 3, 4, 4, 6])

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/20140227/d24a8cb7/attachment.html>


More information about the NumPy-Discussion mailing list