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

Rob Speer rspeer at MIT.EDU
Thu Jul 8 11:49:14 EDT 2010


On Thu, Jul 8, 2010 at 7:13 AM, Lluís <xscript at gmx.net> wrote:
> Thus, we can use something in the middle:
>
>   arr[0,1]
>   arr.names['Netherlands',2010] # I'd rather go for 'names' instead of 'ticks'

Ah ha. So this is the case with positional axes but named ticks, which
we haven't really brought up yet. I'm definitely thinking of making
the top-level datarray support "named" as well, which would make it
into:
>>> arr.named('Netherlands', 2010)

But the other change you've got here is to make "named" into a
__getitem__-able object instead of a method, so you use square
brackets with it and can use slice syntax. I could do it this way as
well.

But I don't understand your second example:
>   arr.country['Spain'].year[1994:2010]

That seems to run straight into the index/name ambiguity. Shouldn't
that take the 1994th through 2010th indices along the "year" axis? Not
every axis will have names, so you can't make *all* the indexing go by
names.

If named were a getitem-able object, that would be:
>>> arr.country.named['Spain'].year.named[1994:2010]

-- Rob



More information about the NumPy-Discussion mailing list