This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

**This is an early release which is not yet battle-nnnhardened. Please file an issue over at github if you encounter problems**

What is pyhistogram

pyhistogram is a pure python package for easy handling of histogram data. It offers much more functionality than pythons build-in 'collections' feature.

pyhistogram interface is heavily inspired by the excellent rootpy package which, however, depends on the gigantic particle physics ROOT framework - an dependency hardly justifiable for small projects. At the moment pyhistogram has no dependencies at all. Matplotlib is optional if one wants to use the built in plotting features. Than also means that this packages performance is nowhere near to that of the rootpy/ROOT solution, but should be sufficient for most use cases. In any case, it is quite possible that numpy might be added as an dependency in the future to use some of its features and to give this package a performance boost.

Currently, pyhistogram only supports one dimensional histograms but is designed with higher dimensions in mind.

Taking it for a spin:

The following shows some, but by far not all features. A proper documentation is on the todo list but for now I can recommend tacking a look at the unittests.

Installing pyhistogram:
pip install pyhistogram

Creating histograms:

from pyhistogram import Hist1D

# 1D histogram with fixed-width bins
h1d = Hist1D(5, -2, 4)
# variable-width bins
h1d = Hist1D([-10, -3.2, 5.2, 35.])

Histograms can be filled in loops:

>>> import random
>>> h = Hist1D(10, -4, 12)
>>> for i in xrange(1000):
>>> h.fill(random.gauss(4, 3))

And one can easily iterate through all the bins:


>>> h = Hist1D(4, 0, 4)
>>> h.fill(1)
>>> [b.value for b in h.bins()]
[1, 0, 0, 0]

A weight can be associated to each value in a 2-tuple:

>>> h = Hist1D(4, 0, 4)
>>> h.fill((1, weight=0.5)
>>> [b.value for b in h.bins()]
[0.5, 0, 0, 0]

datetime support is also no-brainer:

from datetime import datetim
h = Hist1D(4, datetime(2014, 1, 1, 12, 0), datetime(2014, 1, 1, 16, 0))
h.fill(datetime(2014, 1, 1, 13, 0))

And even word frequencies (based on regex) are all there for your convenience:

>>> hist = Hist1D(['My', 'name', 'is', 'Bond'])
>>> [hist.fill(s) for s in ['James', 'Bond']]
>>> [(b.x.regex, b.value) for b in self.hist.bins()]
[('My', 0), ('name', 0), ('is', 0), ('Bond', 1)]

If matplotlib is available, a histogram can also be plotted conveniently:

from pyhistogram import Hist1D
import numpy as np
import matplotlib.pyplot as plt

h = Hist1D(20, -5, 5)
sample = np.random.normal(size=500)
for v in sample:

Running the included unit tests (for (pyhistogram) developers):

$ nosetests pyhistogram
Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pyhistogram-0.1.tar.gz (9.4 kB) Copy SHA256 Checksum SHA256 Source Oct 17, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting