[SciPy-user] Record array help

Johann Rohwer jr@sun.ac...
Mon May 19 09:33:25 CDT 2008


Not sure whether to ask here or on the matplotlib list, but since it's 
mainly a numpy/scipy issue I thought I'd try here first.

Is there any extended documentation/tutorial on record arrays? The NumPy 
book is pretty cryptic about this and I'm still very new to the concept. I'm 
using the csv2rec function from matplotlib (pylab) to generate a record 
array from data that's in a CSV file. The CSV file basically has column 
labels in the first row and numerical data in all subsequent rows. The 
issues I'm struggling with are:

1. Is it possible to change the dtype of a field after the record array has 
been created?

2. The CSV file has missing data points - how do I turn these into python 
'None' elements in the record array? (If I leave that element empty in the 
CSV file, then csv2rec complains about not being able to handle the import; 
if I put 'None' in the CSV file (without quotes), then the whole field 
including the 'None' and all the other float data is converted into a string 
dtype, rendering the numerical data useless).

3. Is it possible to obtain a subset of the original data (corresponding to 
two or more columns of the CSV file) as a conventional 2D numpy array, or 
can I access the data only individually by column (i.e. field in the record 

Any pointers would be appreciated!

More information about the SciPy-user mailing list