[SciPy-User] Suggestion for numpy.genfromtxt documentation
Wed Oct 7 10:52:29 CDT 2009
On Wed, Oct 7, 2009 at 11:25 AM, Dharhas Pothina
> 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
I came across this behavior recently and agree with you. There is a
patch in the works for this.
See this thread: http://thread.gmane.org/gmane.comp.python.numeric.general/33479
And this ticket: http://projects.scipy.org/numpy/ticket/1252
More information about the SciPy-User