fips.Vector.from_series#

classmethod Vector.from_series(series, block=None)[source]#

Build a vector from a Series, reading its labels.

Parameters:
  • series (Series) – Numeric values. With a block level in its index, the vector has those blocks (see Space.from_index()); without one, it has one block, named by block. The Series’ name is the vector’s.

  • block (str | None) – The name of the one block, for a Series without a block level.

Returns:

The values on the Series’ labels. With a block level, the rows of each block are put together, in the order the blocks first appear.

Return type:

Vector

Raises:

ValueError – If a Series with a block level is given block too, one without is given no block, or its labels cannot make a Space.

Examples

>>> import pandas as pd
>>> from fips import Vector
>>> obs = pd.Series(
...     [410.2, 412.8], index=pd.Index(["A", "B"], name="site"), name="obs"
... )
>>> Vector.from_series(obs, block="co2").index
MultiIndex([('co2', 'A'),
            ('co2', 'B')],
           names=['block', 'site'])