Calculate percentage of count for a list of arrays
<p>Simple problem, but I cannot seem to get it to work. I want to calculate the percentage a number occurs in a list of arrays and output this percentage accordingly.
I have a list of arrays which looks like this:</p>

<pre><code>import numpy as np

# Create some data   
listvalues = []

arr1 = np.array([0, 0, 2])
arr2 = np.array([1, 1, 2, 2])
arr3 = np.array([0, 2, 2])

listvalues.append(arr1)
listvalues.append(arr2)
listvalues.append(arr3)

listvalues
&gt;[array([0, 0, 2]), array([1, 1, 2, 2]), array([0, 2, 2])]
</code></pre>

<p>Now I count the occurrences using collections, which returns a a list of collections.Counter:</p>

<pre><code>import collections 

counter = []
for i in xrange(len(listvalues)):
    counter.append(collections.Counter(listvalues[i]))

counter
&gt;[Counter({0: 2, 2: 1}), Counter({1: 2, 2: 2}), Counter({0: 1, 2: 2})]
</code></pre>

<p>The result I am looking for is an array with 3 columns, representing the value 0 to 2 and len(listvalues) of rows. Each cell should be filled with the percentage of that value occurring in the array:</p>

<pre><code># Result
66.66    0      33.33
0        50     50
33.33    0      66.66
</code></pre>

<p>So 0 occurs 66.66% in array 1, 0% in array 2 and 33.33% in array 3, and so on..</p>

<p>What would be the best way to achieve this?
Many thanks!</p>