[Numpy-discussion] BOF notes: Fernando's proposal: NumPy ndarray with named axes
Sun Jul 11 13:09:50 CDT 2010
Robert Kern <robert.kern <at> gmail.com> writes:
> On Sun, Jul 11, 2010 at 11:36, Rob Speer <rspeer <at> mit.edu> wrote:
> >> 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.
> Having ticks on *every* axis is the primary feature there.
I see, thanks.
So for Rob's example slide you could use a record array:
rec = np.rec.fromrecords(data, names='name,305,6,234')
(Here data is a list of tuples, each tuple giving the movie name + it's data.)
In this case it's easy to index by field name (rec['205']), but a trickier to
choose the row using the movie name:
ind = dict((n,i) for i,n in enumerate(rec.name))
rec[ind['Wrong Trousers, The (1993)']]
So datarrays would make this easier.
More information about the NumPy-Discussion