fips.Space.align#

Space.align(other)[source]#

Return where each label of this space is in other: an exact join.

The two spaces must have the same blocks and, in each block, the same labels; their order may differ, and so may the order of a block’s levels. values_on_other[space.align(other)] puts values that follow other in this space’s order.

Parameters:

other (Space) – The space to look the labels up in.

Returns:

For each label of this space, in order, its position in other.index.

Return type:

ndarray

Raises:

ValueError – If a block is in one space and not the other, a block has other levels in other, or a label is in one and not the other. The message names them (the first few of each).

Examples

>>> import pandas as pd
>>> from fips import Space
>>> a = Space({"flux": pd.Index([1, 2, 3], name="cell")})
>>> b = Space({"flux": pd.Index([3, 1, 2], name="cell")})
>>> a.align(b)
array([1, 2, 0])