How to calculate frequency of each number and display results as a table
Question: I have the following numbers:

    
    
    x = [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 4, 4, 4, 4, 5, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 9, 9]
    

Now I want to calculate frequency of each number and display results as a
table using, e.g. [tabulate](https://pypi.python.org/pypi/tabulate).

I calculate frequencies this way:

    
    
    import collections
    
    c = collections.Counter(x)
    count_sum = sum(c.values())
    
    for key,value in c.iteritems():
      print str(key) + " - " + str(float(value) / count_sum)
    

I don't know how to create an array of and pass it to `tabulate`. The ideal
solution would be to use `numpy`.


Answer: Based on comments of Jose Ricardo Bustos M. and JonasL:

The answer for Python 2.8 is:

    
    
    print(tabulate([[key,float(val)/count_sum] for key,val in c.iteritems()]))
    

To get numbers from x, it is necessary to use `key`, while `val` defines
absolute frequency (count) of a number.

