Sounds fair to me. Indeed the ducktyping argument makes sense, and I have a hard time imagining any namespace conflicts or other confusion. Should this attribute return none for non-structured arrays, or simply be undefined?
On Tue, Sep 30, 2014 at 12:49 PM, John Zwinck <jzwi...@gmail.com> wrote: > I first proposed this on GitHub: > https://github.com/numpy/numpy/issues/5134 ; jaimefrio requested that > I bring it to this list for discussion. > > My proposal is to add a keys() method to NumPy's array class ndarray. > The behavior would be to return self.dtype.names, i.e. the "column > names" for a structured array (and None when dtype.names is None, > which it is for pure numeric arrays without named columns). > > I originally proposed to add a values() method also, but I am tabling > that for now so we needn't discuss it in this thread. > > The motivation is to enhance the ability to use duck typing with NumPy > arrays, Python dicts, and other types like Pandas DataFrames, h5py > Files, and more. It's a fairly common thing to want to get the "keys" > of a container, where "keys" is understood to be a sequence of values > one can pass to __getitem__(), and this is exactly what I'm aiming at. > > Thoughts? > > John Zwinck > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion