From python Counter dictionary to nd numpy array
<p>I know this is a very classic question, but after going through many posts, I decided to bring it back, without being able to find an elegant solution for something seemingly basic.
   The problem: </p>

<p>I have a Counter dictionary from a large data set, with meaningful integer keys, and integer occurrences:</p>

<pre><code>co = Counter({8046: 1360, 10046: 1248, 11046: 1024})
</code></pre>

<p>And I <em>simply</em> want to end up with a basic integer array:</p>

<pre><code>a = np.array([[8046,1360],[10046,1248],[11046,1024]])
</code></pre>

<p>The specificity of this problem (or the absence of specificity) is that I have integer keys, and I don't need a structured array. The following</p>

<pre><code>dtype = dict(names = ['id','data'], formats=['i8','i8'])
array = np.fromiter(iter(co.items()), dtype=dtype)
</code></pre>

<p>is not quite satisfying, ending up with</p>

<pre><code>a = [(8046, 1360) (10046, 1248) (11046, 1024)]
</code></pre>

<p>Is it just a question of dtype? Thanks a lot!</p>