I would appreciate any help please :)
I'm trying to create a record array from 1d array of strings and 2d array of numbers (so I can use np.savetxt and dump it into a file). Unfortunately the docs aren't informative: np.core.records.fromarrays
>>> import numpy as np
>>> x = ['a', 'b', 'c']
>>> y = np.arange(9).reshape((3,3))
>>> print x
['a', 'b', 'c']
>>> print y
[[0 1 2]
[3 4 5]
[6 7 8]]
>>> records = np.core.records.fromarrays([x,y])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/numpy/core/records.py", line 560, in fromarrays
raise ValueError, "array-shape mismatch in array %d" % k
ValueError: array-shape mismatch in array 1
And the output I need is:
[['a', 0, 1, 2]
['b', 3, 4, 5]
['c', 6, 7, 8]]
xshould be an array, right? Currently it is a list.