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

Neil Crighton neilcrighton at gmail.com
Mon Jul 12 09:04:55 EDT 2010


Gael Varoquaux <gael.varoquaux <at> normalesup.org> writes:

> Let say that you have a dataset that is in a 3D array, where axis 0
> corresponds to days, axis 1 to hours of the day, and axis 2 to
> temperature, you might want to have the mean of the temperature in each
> day, which would be in current numpy:
> 
>     data.mean(axis=0)
> 
> or the mean of the temperature at every hour, across the different days,
> which would be:
> 
>     data.mean(axis=1)
> 
> I do such manipulation all the time, and keeping track of which axis is
> what is fairly tedious and error prone. It would be much nicer to be able
> to write:
> 
>     data.ax_day.mean(axis=0)
>     data.ax_hour.mean(axis=0)
> 

Thanks, that's a really nice description. Instead of

data.ax_day.mean(axis=0)

I think it would be clearer to do something like 

data.mean(axis='day')

but I see the motivation.


Neil







More information about the NumPy-Discussion mailing list