fips.Space.from_index#
- classmethod Space.from_index(index)[source]#
Build the space an index with a
blocklevel describes.Each block gets the levels it has labels on; a level that is missing (NaN) on every row of a block is padding and is dropped. A block’s labels keep the order of its rows in index, and the blocks the order in which they first appear. The levels keep their order in index.
- Parameters:
index (
Index) – Labels with ablocklevel, such asindexor the index of aVector.- Returns:
The space whose blocks the index holds.
- Return type:
- Raises:
ValueError – If index has no
blocklevel, a row has no block name, a block has no other level, or a block has labels on a level for some of its rows and not for others.
Examples
>>> import pandas as pd >>> from fips import Space >>> index = pd.MultiIndex.from_tuples( ... [("flux", 1.0, None), ("flux", 2.0, None), ("bias", None, "A")], ... names=["block", "cell", "site"], ... ) >>> Space.from_index(index).select("bias").tolist() ['A']