[Numpy-discussion] BOF notes: Fernando's proposal: NumPy ndarray with named axes

Neil Crighton neilcrighton@gmail....
Sun Jul 11 06:59:30 CDT 2010

Robert Kern <robert.kern <at> gmail.com> writes:
> Please install Fernando's datarray package, play with it, read its
> documentation, then come back with objections or alternatives. I
> really don't think you understand what is being proposed.

Well the discussion has been pretty confusing. For mostly my
benefit, here's my understanding of the proposal.

Currently the only way to choose which axis of an array we want
is by the indexing position.  So to access a row of a 2d
array (axis=0)

a[0,:]  or just a[0]     # first row

and a column (axis=1)

a[:,0]    # first column

To choose an individual element along an axis we must use integer

a[0,3]   # the element that is 1st along the 1st axis and 
         # 4th along the 2nd axis

Fernando's proposal would allow us to specify the axis by a
name (called a label) instead of a position, and the element
number by a name (called a tick) instead of an integer, while
retaining the old position + integer indexing. Ticks are in
effect "named indices".  I can see the attraction of accessing an
axis by name instead of indexing position, because it's easy to
get confused over position when you've got a 2d or higher
dimension array. But the utility of named indices is not so clear
to me. As I understand it, these new arrays will still only be
able to have a single type of data (one of float, str, int and so
on). This seems to be pretty limiting.

What is a use case for the new array type that can't be solved by
structured/record arrays?  Sounds like it was decided at the Sciy
BOF they were a good idea, several people have implemented a
version of them and Fernando and Gael have both said they find
them useful, so they must have something going for them.  Maybe
Fernando or Gael could share an example where arrays with named
axes and indices are especially useful, for the peanut gallery's

Cheers, Neil

More information about the NumPy-Discussion mailing list