[Numpy-discussion] histogram for discrete data

Ernest Adrogué eadrogue at gmx.net
Sun Dec 6 07:26:24 EST 2009


Hi,

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])
Out[17]: 
array([[-1.,  2.],
       [ 0.,  1.],
       [ 5.,  1.]])

Bye.



More information about the NumPy-Discussion mailing list