Binning frequency distribution in Python
Question: I have data in the two lists _value_ and _freq_ like this:

    
    
    value freq
    1      2
    2      1
    3      3
    6      2
    7      3
    8      3
    ....
    

and I want the output to be

    
    
    bin freq
    1-3   6
    4-6   2
    7-9   6
    ...
    

I can write few lines of code to do this. However, I am looking if there are
builitin functions in standard python or Numpy? I found the solution when you
are given data in array/list with repetition i.e. they are not already grouped
into frequency table(eg. ` d= [1,1,2,3,3,3,6,6,7,7,7,8,8,8,...]`. However, in
this case I could not find the answers. I do not want to convert my data into
single expanded list like `d` first and use histogram function.


Answer: 
    import numpy as np
    values = [1,2,3,6,7,8]
    freqs = [2,1,3,2,3,3]
    
    hist, _ = np.histogram(values, bins=[1, 4, 7, 10], weights=freqs)
    print hist
    

output:

    
    
    [6 2 6]
    

