Reputation: 6248
I was using numpy, MySQLbb and scipy and ended up with an array of tuples from a MySQL cursor execution. Then I used np.fromiter. Now I have an array of tuples that looks like this:
>>> A
array([('bob', 0.43), ('dan', 0.24), ('bill', 0.14)
('sharen', 0.28), ..., ('zena', 0.24), ('zoe', 0.39)],
dtype = [('f0', 'S10'), ('f1', '<f4')])
How do I make a numpy array for the first part of each tuple? I tried:
>>> Names = A[:][0]
I also tried:
>>> Names = np.array(A[:][0])
But that didn't work; only gave me the first tuple. I couldn't find any documentation for that specific example.
I want an numpy array like this:
>>> Names
array[('bob', 'bill', all the other names...
>>> Numbers
array[(0.43, 0.24, etc...
Thanks in advance.
Upvotes: 4
Views: 1137