lenskit.data.AttributeSet#
- class lenskit.data.AttributeSet(name, spec, table, vocab, rows)#
Bases:
objectBase class for attributes associated with entities.
This is the general interface for attribute sets. Not all access methods are supported for all layouts.
- Stability:
- Caller (see Stability Levels).
- Parameters:
name (str)
spec (ColumnSpec)
table (pa.Table)
vocab (Vocabulary)
rows (pa.Int32Array | None)
- __init__(name, spec, table, vocab, rows)#
- Parameters:
name (str)
spec (ColumnSpec)
table (Table)
vocab (Vocabulary)
rows (Int32Array | None)
Methods
__init__(name, spec, table, vocab, rows)arrow()Get the attribute values as an Arrow array.
Subset this attribute set to only entities for which it is defined.
id_index()Get the entity IDs as a Pandas index.
ids()Get the entity IDs for the rows in this attribute's values.
numbers()Get the entity numbers for the rows in this attribute's values.
numpy()Get the attribute values as a NumPy array.
pandas(*[, missing])scipy()Get this attribute as a SciPy sparse array (if it is sparse), or a NumPy array if it is dense.
torch()Attributes
Get the names attached to this attribute's dimensions.
Query whether this attribute is a list.
Query whether this attribute is scalar.
Query whether this attribute is a sparse vector.
Query whether this attribute is a dense vector.
The name of the attribute.
- ids()#
Get the entity IDs for the rows in this attribute’s values.
- numbers()#
Get the entity numbers for the rows in this attribute’s values.
- property dim_names: list[str] | None#
Get the names attached to this attribute’s dimensions.
Note
Only applicable to vector and sparse attributes.
- numpy()#
Get the attribute values as a NumPy array.
Note
Undefined attribute values may have undefined contents; they will _usually_ be
NaNor similar, but this is not fully guaranteed.
- arrow()#
Get the attribute values as an Arrow array.
- Return type:
pa.Array[Any] | pa.ChunkedArray[Any]
- scipy()#
Get this attribute as a SciPy sparse array (if it is sparse), or a NumPy array if it is dense.
- drop_null()#
Subset this attribute set to only entities for which it is defined.