I have a problem with NumPy dtypes. Essentially, I'm trying to create a table that looks like this (and then saves it using rec2csv):
name1 name2 name3 . . . name1
The matrix (a numerical array in the center) is already calculated before I try to add name tags. I tried using the following code:
dt = dtype({'names' : tuple(blah), 'formats' : tuple(fmt)}) ReadArray = array(tuplelist, dtype=dt)
where tuplelist is a list of strings (for example, the string [name1, #, #, # ...]), blah is a list of strings (that is, names, blah = ['name1', 'name2', ...] ) , and fmt is a list of formats, s (ie fmt = [str, float, float, ...] ).
The error I am 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!
python numpy
Tarun chitra
source share