[Numpy-discussion] histogram for discrete data

Ernest Adrogué eadrogue@gmx....
Sun Dec 6 06:26:24 CST 2009


A few weeks ago there was a discussion about a
histogram_discrete() function --sorry for starting a new
thread but I have lost the mails.

Somebody pointed out that bincount() already can be used
to histogram discrete data (except that it doesn't work
with negative values).

I have just discovered a function in scipy.stats called
itemfreq() that does handle negative values.

In [17]: scipy.stats.itemfreq([-1,-1,0,5])
array([[-1.,  2.],
       [ 0.,  1.],
       [ 5.,  1.]])


More information about the NumPy-Discussion mailing list