tdfs4ds.feature_attrs¶
tdfs4ds.feature_attrs
¶
Attributes of features, read from a dataset whose entity is the feature name (0.3.7.22).
A feature attribute dataset is a registered dataset (primary store) one of whose entity columns
is named FEATURE_NAME (case-insensitive): one row per feature, the other columns describe it
(an exclusion flag and its reason, an owner, a review date...). Nothing is declared apart from
that: build such a dataset with build_dataset or upload_features(dataset_view_name=...)
from a process whose entity is FEATURE_NAME.
A feature's identity is the triplet (DATA_DOMAIN, ENTITY_NAME, FEATURE_NAME). When the attribute
dataset also has ENTITY_NAME and/or DATA_DOMAIN (entity or plain columns) they narrow the
match; a bare name that matches several catalog features applies to all of them and is reported
as ambiguous, never guessed.
Layers: :func:attribute_datasets (recognition, pure over two catalog frames),
:func:match_attribute_rows (matching, pure), :func:feature_attributes (the only I/O: one
SELECT * per attribute dataset). Fail-open: an unreadable dataset is listed in
frame.attrs["errors"], never raised.
The module is named feature_attrs because a module named feature_attributes would shadow
the function exported at tdfs4ds.feature_attributes.
BASE_COLUMNS
module-attribute
¶
__all__
module-attribute
¶
__all__ = ['attribute_datasets', 'match_attribute_rows', 'feature_attributes', 'attribute_columns', 'attributes_of', 'attribute_row', 'BASE_COLUMNS']
attribute_datasets
¶
attribute_datasets(ds_catalog: Optional[DataFrame] = None, ds_entity: Optional[DataFrame] = None) -> list
The registered datasets whose entity has a FEATURE_NAME column.
Without arguments the two dataset-catalog frames are read (primary store, one raw read each).
Returns [{"dataset_id", "database", "name", "entity_columns"}] sorted by name; [] when
the catalog is empty or unreadable.
match_attribute_rows
¶
Match the rows of one attribute dataset to catalog features.
features: frame with DATA_DOMAIN, ENTITY_NAME, FEATURE_NAME. columns/rows: the dataset's
SELECT *. Names compare case-insensitively; a DATA_DOMAIN / ENTITY_NAME value in the row
narrows the candidates. Returns (matched, ambiguous, unmatched): matched a list of
dicts (the triplet + every non-key column), ambiguous the rows that applied to several
features, unmatched the feature names the catalog does not have.
_merge
¶
One frame from the datasets' matches: a column two datasets share is prefixed by the dataset name, the triplets are joined (outer) and ATTRIBUTE_DATASET names the sources.
attribute_columns
¶
The attribute columns of a :func:feature_attributes frame (everything but the triplet
and ATTRIBUTE_DATASET).
attribute_row
¶
The row of one feature (triplet; entity / domain may be blank to match any), the
first matching one, or None.
attributes_of
¶
{column: value} of one feature (see :func:attribute_row), empty values left out;
{} when none.
_select_star
¶
(columns, rows) of a dataset view, current valid time (the view bakes it in).
feature_attributes
¶
feature_attributes(features=None, data_domains=None, as_of=None, *, catalog: Optional[DataFrame] = None, ds_catalog: Optional[DataFrame] = None, ds_entity: Optional[DataFrame] = None, read: Optional[Callable] = None) -> pd.DataFrame
Attributes of features, one row per feature, from the attribute datasets of the store.
Columns: DATA_DOMAIN, ENTITY_NAME, FEATURE_NAME, every other column of the attribute
dataset(s) (a column two datasets share is prefixed by the dataset name), ATTRIBUTE_DATASET.
features: names to keep (a string or a list, case-insensitive); data_domains: domains to
keep. The result is empty (columns of the triplet only) when the store has no attribute
dataset. frame.attrs carries datasets (their names), errors ({dataset: message}),
ambiguous (rows applied to several features), unmatched ({dataset: names the catalog
does not have}) and, when as_of is given, as_of_note: the dataset views carry their own
CURRENT VALIDTIME, so the values are read at the current valid time.
The injection arguments (catalog, ds_catalog, ds_entity, read) serve the consumer agent (frames of its per-turn snapshot) and the tests.