Suppose I have a collection of objects which I wish to save in python, say, a list of numbers: [0.12, 0.85, 0.11, 0.12], [0.23, 0.52, 0.10, 0.19], etc. Suppose further that these objects are indexed by 3 attributes, say, "origin", "destination", and "month". I wish to store these objects in an array-like object which can be easily sliced, ideally using either numerical index or a name.
So, i.e.,
obj[2,1,7] # might return: [0.23, 0.52, 0.10, 0.19]
Or,
obj['chicago','new york','jan'] # might return: [0.12, 0.85, 0.11, 0.12]
And further,
obj[:,'new york','jan'] # would return data with first index = any.
I'm looking for the best practice to achieve this in python. I did find this post, which seems quite suitable, but it seemed to require some overhead and there was little discussion of alternatives. I also found something called the xarray package, though this doesn't seem as popular. I am transitioning form R, where I would do this the array() function, which adds a multi-dimensional index to any vector-like structure.