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 ablocklevel in its index, the vector has those blocks (seeSpace.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 ablocklevel.
- Returns:
The values on the Series’ labels. With a
blocklevel, the rows of each block are put together, in the order the blocks first appear.- Return type:
- Raises:
ValueError – If a Series with a
blocklevel is given block too, one without is given no block, or its labels cannot make aSpace.
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'])