[SciPy-User] Suggestion for numpy.genfromtxt documentation

Dharhas Pothina Dharhas.Pothina@twdb.state.tx...
Wed Oct 7 10:25:37 CDT 2009


Hi,

It took me a while and a lot of trial and error to work out why this didn't work as expected.

data = np.genfromtxt(fname,usecols=(2,3,4),names='x,y,z')

this command works and does not return any warnings or errors, but returns an numpy array with no field names. If you use:

data = np.genfromtxt(fname,usecols=(2,3,4),dtype=None,names='x,y,z')

then the command does what I expect it to and returns a structured numpy array with field names. So essentially, the 'names' argument doesn't not work unless you also specify the 'dtype' argument.

I think, it would be less confusing to new users to either have this explicitly mentioned in the documentation string for the genfromtxt 'names' argument or to have the function default to 'dtype=None'  if the 'names' argument is specified without specifying the 'dtype' argument.

- dharhas



More information about the SciPy-User mailing list