def compute_histogram(data, labels): histogram = dict(itemfreq(data)) for label in labels: if label not in histogram: histogram[label] = .0 return histogram