daf.typing.vectors

The types here describe a 1D numpy.ndarray, which can be fetched from daf.

Data:

Vector(x)

Functions:

is_vector(data, *[, dtype, size])

Check whether some data is a Vector, optionally only of some dtype, optionally only of some size.

be_vector(data, *[, dtype, size])

Assert that some data is a Vector, optionally only of some dtype, optionally only of some size, and return it as such for mypy.

as_vector(data, *[, force_copy])

Access the internal 1D numpy array, if possible; otherwise, or if force_copy, return a copy of the 1D data as a numpy array.

daf.typing.vectors.Vector

1-dimensional numpy array of bool values.

alias of ndarray

daf.typing.vectors.is_vector(data: Any, *, dtype: Optional[_dtypes.DTypes] = None, size: Optional[int] = None) TypeGuard[Vector][source]

Check whether some data is a Vector, optionally only of some dtype, optionally only of some size.

By default, checks that the data type is one of ALL_DTYPES.

daf.typing.vectors.be_vector(data: Any, *, dtype: Optional[Union[str, dtype, Collection[str], Collection[dtype], Collection[Union[str, dtype]]]] = None, size: Optional[int] = None) Vector[source]

Assert that some data is a Vector, optionally only of some dtype, optionally only of some size, and return it as such for mypy.

By default, checks that the data type is one of ALL_DTYPES.

daf.typing.vectors.as_vector(data: Union[Sequence[Any], ndarray, _fake_sparse.spmatrix, Series, DataFrame], *, force_copy: bool = False) Vector[source]

Access the internal 1D numpy array, if possible; otherwise, or if force_copy, return a copy of the 1D data as a numpy array.

Accepts as input data types that aren’t even a Vector; it will convert a list or a matrix with a single row or a single column into a 1D numpy array.

This ensures that pandas strings (even if categorical) will be converted to proper numpy strings.