larray.AxisCollection.iter_labels
- AxisCollection.iter_labels(axes=None, ascending=True) Sequence[Tuple[IGroup, ...]] [source]
Return a view of the axes labels.
- Parameters
- axesint, str or Axis or tuple of them, optional
Axis or axes along which to iterate and in which order. Defaults to None (all axes in the order they are in the collection).
- ascendingbool, optional
Whether to iterate the axes in ascending order (from start to end). Defaults to True.
- Returns
- Sequence
An object you can iterate (loop) on and index by position.
Examples
>>> from larray import ndtest >>> axes = ndtest((2, 2)).axes >>> axes AxisCollection([ Axis(['a0', 'a1'], 'a'), Axis(['b0', 'b1'], 'b') ]) >>> axes.iter_labels()[0] (a.i[0], b.i[0]) >>> for index in axes.iter_labels(): ... print(index) (a.i[0], b.i[0]) (a.i[0], b.i[1]) (a.i[1], b.i[0]) (a.i[1], b.i[1]) >>> axes.iter_labels(ascending=False)[0] (a.i[1], b.i[1]) >>> for index in axes.iter_labels(ascending=False): ... print(index) (a.i[1], b.i[1]) (a.i[1], b.i[0]) (a.i[0], b.i[1]) (a.i[0], b.i[0]) >>> axes.iter_labels(('b', 'a'))[0] (b.i[0], a.i[0]) >>> for index in axes.iter_labels(('b', 'a')): ... print(index) (b.i[0], a.i[0]) (b.i[0], a.i[1]) (b.i[1], a.i[0]) (b.i[1], a.i[1]) >>> axes.iter_labels('b')[0] (b.i[0],) >>> for index in axes.iter_labels('b'): ... print(index) (b.i[0],) (b.i[1],)