[Numpy-discussion] histogram for discrete data
Sun Dec 6 06:52:55 CST 2009
2009/12/6 Ernest Adrogué <email@example.com>:
> 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 : scipy.stats.itemfreq([-1,-1,0,5])
> array([[-1., 2.],
> [ 0., 1.],
> [ 5., 1.]])
bincount is a fast c function, stats.itemfreq uses a slow python loop.
The latter should be very slow for large arrays.
stats.itemfreq works also on floats, but not on strings (which should be a bug).
> NumPy-Discussion mailing list
More information about the NumPy-Discussion