fips.Vector.from_blocks#

classmethod Vector.from_blocks(blocks, name=None)[source]#

Build a vector from one Series (or vector of one block) for each block.

Parameters:
  • blocks (Mapping[str, Series | Vector]) – Each block’s name mapped to its values, in the order the blocks should have: a Series labeled by the block’s own index (no block level), or a Vector of one block (its labels and values; the key names the block).

  • name (str | None) – The vector’s name.

Returns:

The values of every block, on the Space of the blocks’ indexes.

Return type:

Vector

Raises:

ValueError – If a vector given for a block has more than one block, or the labels cannot make a Space.

Examples

>>> import pandas as pd
>>> from fips import Vector
>>> f = Vector.from_blocks(
...     {"flux": pd.Series([1.0, 2.0], index=pd.Index([1, 2], name="cell"))}
... )
>>> f.space
Space(flux: 2 x ['cell'])