Hi,
I just am having a problem with NumPy dtypes. Essentially I'm trying to create a table that looks like the following (and then save it using rec2csv):
name1 name2 name3 . . .
name1 # # #
name2 # # #
name2 # # #
.
.
.
The matrix (numerical array in the center), is already computed before I attempt to add the name tags. I've tried to use the following code:
dt = dtype({'names' : tuple(blah), 'formats' : tuple(fmt)})
ReadArray = array(tuplelist, dtype=dt)
where tuplelist is a list of rows (i.e. the row [name1, #, #, #...]), blah is a list of strings (i.e. the names, blah = ['name1', 'name2', ...]
) and fmt is the list of format,s (i.e. fmt = [str, float, float, ...]
).
The error I'm getting is the following:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "table_calc_try2.py", line 152, in table_calc_try2
dt = dtype({'names' : tuple(blah), 'formats' : tuple(fmt)})
TypeError: data type not understood
Can anyone help?
Thanks!