skfolio.containers.Field2D#
- class skfolio.containers.Field2D(values, *, inactive_policy=MISSING)[source]#
Numeric 2D field with axes (observations, assets).
- Parameters:
- valuesndarray of shape (n_observations, n_assets)
Numeric field values. Object dtype is rejected. Use
FieldCategoricalfor categorical data.
- Attributes:
dtypeDtype of the underlying values.
- inactive_policy
is_3dWhether or not the field is a 3D field.
is_categoricalWhether or not the field is a categorical field.
missing_maskReturn a boolean mask indicating missing entries.
n_assetsNumber of assets.
n_observationsNumber of observations.
ndimNumber of dimensions of the underlying values.
shapeShape of the underlying values.
- values
Methods
copy(*[, deep])Return a copy of the field.
with_values(values)Return a field of the same type with replacement values.
- copy(*, deep=False)#
Return a copy of the field.
- Parameters:
- deepbool, default=False
If
True, copy NumPy arrays stored by the field. IfFalse, reuse the same array objects.
- Returns:
- fieldBaseField
Field instance of the same concrete class.
- property dtype#
Dtype of the underlying values.
- property is_3d#
Whether or not the field is a 3D field.
- property is_categorical#
Whether or not the field is a categorical field.
- property missing_mask#
Return a boolean mask indicating missing entries.
- Returns:
- maskndarray of bool
Boolean array with the same shape as
values. Entries areTruewherevaluesis NaN for floating-point fields andFalseelsewhere. Non-floating fields without a missing-value convention return an all-Falsemask; subclasses override this method when they define their own convention.
- property n_assets#
Number of assets.
- property n_observations#
Number of observations.
- property ndim#
Number of dimensions of the underlying values.
- property shape#
Shape of the underlying values.
- with_values(values)#
Return a field of the same type with replacement values.
Metadata arrays are reused. The replacement values are validated by the concrete field class constructor.
- Parameters:
- valuesarray-like
Replacement field values.
- Returns:
- fieldBaseField
Field instance of the same concrete class.