3d numpy record array
Actually, you can do something similar to this with structured arrays, but it's generally more trouble than it's worth.
What you want is basically labeled axes.
Pandas (which is built on top of numpy) provides what you want, and is a better choice if you want this type of indexing. There's also Larry (for labeled array), but it's largely been superseded by Pandas.
Also, you should be looking at the numpy documentation for structured arrays for info on this, rather than an FAQ. The numpy documentation has considerably more information. http://docs.scipy.org/doc/numpy/user/basics.rec.html
If you do want to take a pure-numpy route, note that structured arrays can contain multidimensional arrays. (Note the shape argument when specifying a dtype.) This will rapidly get more complex than it's worth, though.
In pandas
terminology, what you want is a Panel
. You should probably get familiar with DataFrame
s first, though.
Here's how you'd do it with Pandas:
import numpy as npimport pandasd = np.array(np.arange(3*2*6).reshape(3,2,6))dat = pandas.Panel(d, items=['temp', 'precip', 'humidity'], major_axis=['yr1', 'yr2'], minor_axis=['jan', 'feb', 'mar', 'apr', 'may', 'jun'])print dat['temp']print dat.major_xs('yr1')print dat.minor_xs('may')