AxisCollection.get(self, key, default=None, name=None)[source]

Returns axis corresponding to key. If not found, the argument name is used to create a new Axis. If name is None, the default axis is then returned.


Key corresponding to an axis of the current AxisCollection.

defaultaxis, optional

Default axis to return if key doesn’t correspond to any axis of the collection and argument name is None.

namestr, optional

If key doesn’t correspond to any axis of the collection, a new Axis with this name is created and returned.


>>> age = Axis(range(20), 'age')
>>> sex = Axis('sex=M,F')
>>> time = Axis([2007, 2008, 2009, 2010], 'time')
>>> col = AxisCollection([age, time])
>>> col.get('time')
Axis([2007, 2008, 2009, 2010], 'time')
>>> col.get('sex', sex)
Axis(['M', 'F'], 'sex')
>>> col.get('nb_children', None, 'nb_children')
Axis(1, 'nb_children')