DataVec API¶
DataVec extends pandas.Series with linear-algebra friendly behaviour. The
reference below is generated directly from the docstrings, so it stays in sync
with the code.
Bases: Series
Column vector with labeled index for linear-algebra operations.
__getitem__(key)
¶
v.getitem(k) == v[k]
v = DataVec({'a':1,'b':2}) v['a'] 1
__init__(data=None, **kwargs)
¶
Create a DataVec.
Inherit from :meth: pd.Series.__init__.
Additional Parameters¶
idxnames (List of) name(s) for levels of index.
dg(sparse=True)
¶
Return the diagonal matrix diag(v).
drop_vestigial_levels()
¶
Drop index levels that don't vary.
inv()
¶
Inverse of a vector defined for 1-vector case.
norm(ord=None, **kwargs)
¶
Vector norm āvā_ord (defaults to the Euclidean norm).
outer(other)
¶
Outer product of two series (vectors).
proj(other)
¶
Projection of self on other.
random(size, distribution='normal', *, index=None, idxnames=None, name=None, rng=None, **dist_kwargs)
classmethod
¶
Draw a random vector with optional labelled index.
Parameters¶
size : int
Length of the vector.
distribution : random-spec, default "normal"
Name/tuple/callable describing the distribution. Built-in shorthands:
- "normal" / "gaussian" (loc, scale)
- "uniform" (low, high)
- "chi2" / "chisquare" (df)
- "exponential" (scale)
- "bernoulli" (p)
- "binomial" (n, p)
- "poisson" (lam)
- "standard_normal"
A tuple like ("chi2", 3) maps to the appropriate parameters.
Custom callables must accept size= and return an array.
index : Sequence or pandas.Index, optional
Values for the index; defaults to 0..size-1.
idxnames : str or sequence of str, optional
Name(s) applied to the index levels.
name : str, optional
Vector name; defaults to an auto-generated vec_* identifier.
rng : numpy.random.Generator | int | None, optional
RNG or seed used by the draw (falls back to default_rng()).
**dist_kwargs
Additional keyword arguments forwarded to the distribution.
Returns¶
DataVec
Labelled random vector of shape (size,).
resid(other)
¶
Residual from projection of self on other.