Spaces and Vectors#
A Space is the labels of a state, of the observations, or of one
axis of a matrix: an ordered set of named blocks, each labeled by its own
pandas index. A Vector is values on a space, one for each label.
fips keeps labels as they are given: it does not convert them to numbers or
round them, and it refuses duplicate and missing labels.
In [1]: import pandas as pd
In [2]: import fips
In [3]: prior = fips.Vector.from_blocks(
...: {
...: "flux": pd.Series([1.0, 2.0], index=pd.Index([1, 2], name="cell")),
...: "bias": pd.Series([0.0], index=pd.Index(["A"], name="site")),
...: },
...: name="prior",
...: )
...:
In [4]: prior.space
Out[4]: Space(flux: 2 x ['cell'], bias: 1 x ['site'])
In [5]: prior.to_series()
Out[5]:
block cell site
flux 1 nan 1.0
2 nan 2.0
bias NaN A 0.0
Name: prior, dtype: float64
In [6]: prior["flux"].space.select("flux")
Out[6]: Index([1, 2], dtype='int64', name='cell')
A vector of one block is a single component of the state or of the
observations: fips.Vector.from_series(series, block="flux").
Space#
Constructor#
|
An ordered set of named blocks, each labeled by its own pandas index. |
|
Build the space an index with a |
Attributes#
The names of the blocks, in order. |
|
The names of the levels after |
|
The labels of every block as one MultiIndex, with the |
|
Where each block starts in |
Selection#
|
Return the labels of block, as the block was given. |
|
Return the positions of block in |
Alignment and labels#
|
Return where each label of this space is in other: an exact join. |
|
Return the space with every float level rounded to decimals places. |
Vector#
Constructor#
|
Values on a |
|
Build a vector from a Series, reading its labels. |
|
Build a vector from one Series (or vector of one block) for each block. |
Attributes#
The values, one for each label, in the space's order (read-only). |
|
The labels of the values. |
|
a string, or None. |
|
The labels as one MultiIndex with the |
Selection and conversion#
|
Return the vector of one block. |
|
Return the values as a Series: the whole vector, or one block on its own labels. |
Return the values as xarray, each block on its own levels. |
Alignment and labels#
|
Return the values on space, which must have exactly the same labels. |
|
Return other with this vector's values where this vector has the label. |
|
Return the vector with its float labels rounded ( |