[Numpy-discussion] New functions.

Skipper Seabold jsseabold@gmail....
Wed Jun 1 11:32:09 CDT 2011


On Wed, Jun 1, 2011 at 11:31 AM, Mark Miller <markperrymiller@gmail.com> wrote:
> I'd love to see something like a "count_unique" function included. The
> numpy.unique function is handy, but it can be a little awkward to
> efficiently go back and get counts of each unique value after the
> fact.
>

Does bincount do what you're after?

[~/]
[1]: x = np.random.randint(1,6,5)

[~/]
[2]: x
[2]: array([1, 3, 4, 5, 1])

[~/]
[3]: np.bincount(x)
[3]: array([0, 2, 0, 1, 1, 1])

Skipper


More information about the NumPy-Discussion mailing list