<a id="skfolio-containers-field3d"></a>

# skfolio.containers.Field3D

<a id="skfolio.containers.Field3D"></a>

### *class* skfolio.containers.Field3D(values, third_axis_name, third_axis_labels, third_axis_groups=None, \*, inactive_policy=MISSING)

Numeric 3D field with axes (observations, assets, third_axis).

Use this field for homogeneous tensors (e.g. factor exposures). The third-axis
metadata is stored on the field. The array is stored physically in 3D so that
operations along any axis remain vectorized and avoid stacking many 2D arrays which
is expensive for large panels. When you need repeated tensor operations, prefer a
`Field3D` instead of multiple `Field2D`.

* **Parameters:**
  **values** *ndarray of shape `(n_observations, n_assets, n_third_axis)`*
  : Numeric 3D values. Object dtype is rejected.

  **third_axis_name** *str*
  : Name describing what the third axis represents (e.g. `factor`).

  **third_axis_labels** *ndarray of shape (n_third_axis,)*
  : Labels for entries along the third axis such as factor names (`size`,
    `momentum`). Labels must be unique.

  **third_axis_groups** *ndarray of shape (n_third_axis,), optional*
  : Optional group label for each third-axis entry such as factor families (e.g.
    `style`, `industry`, `country`).
* **Attributes:**
  [`dtype`](#skfolio.containers.Field3D.dtype)
  : Dtype of the underlying values.

  **inactive_policy**

  [`is_3d`](#skfolio.containers.Field3D.is_3d)
  : Whether or not the field is a 3D field.

  [`is_categorical`](#skfolio.containers.Field3D.is_categorical)
  : Whether or not the field is a categorical field.

  [`missing_mask`](#skfolio.containers.Field3D.missing_mask)
  : Return a boolean mask indicating missing entries.

  [`n_assets`](#skfolio.containers.Field3D.n_assets)
  : Number of assets.

  [`n_observations`](#skfolio.containers.Field3D.n_observations)
  : Number of observations.

  [`ndim`](#skfolio.containers.Field3D.ndim)
  : Number of dimensions of the underlying values.

  [`shape`](#skfolio.containers.Field3D.shape)
  : Shape of the underlying values.

  **third_axis_groups**

  **third_axis_labels**

  **third_axis_name**

  **values**

### Methods

| [`copy`](#skfolio.containers.Field3D.copy)(\*[, deep])    | Return a copy of the field.                              |
|----------------------------------------------------------------------|----------------------------------------------------------|
| [`with_values`](#skfolio.containers.Field3D.with_values)(values) | Return a field of the same type with replacement values. |

<a id="skfolio.containers.Field3D.copy"></a>

#### copy(\*, deep=False)

Return a copy of the field.

* **Parameters:**
  **deep** *bool, default=False*
  : If `True`, copy NumPy arrays stored by the field. If `False`, reuse the same
    array objects.
* **Returns:**
  **field** *BaseField*
  : Field instance of the same concrete class.

<a id="skfolio.containers.Field3D.dtype"></a>

#### *property* dtype

Dtype of the underlying values.

<a id="skfolio.containers.Field3D.is_3d"></a>

#### *property* is_3d

Whether or not the field is a 3D field.

<a id="skfolio.containers.Field3D.is_categorical"></a>

#### *property* is_categorical

Whether or not the field is a categorical field.

<a id="skfolio.containers.Field3D.missing_mask"></a>

#### *property* missing_mask

Return a boolean mask indicating missing entries.

* **Returns:**
  **mask** *ndarray of bool*
  : Boolean array with the same shape as `values`. Entries are `True`
    where `values` is NaN for floating-point fields and `False` elsewhere.
    Non-floating fields without a missing-value convention return an all-`False`
    mask; subclasses override this method when they define their own convention.

<a id="skfolio.containers.Field3D.n_assets"></a>

#### *property* n_assets

Number of assets.

<a id="skfolio.containers.Field3D.n_observations"></a>

#### *property* n_observations

Number of observations.

<a id="skfolio.containers.Field3D.ndim"></a>

#### *property* ndim

Number of dimensions of the underlying values.

<a id="skfolio.containers.Field3D.shape"></a>

#### *property* shape

Shape of the underlying values.

<a id="skfolio.containers.Field3D.with_values"></a>

#### 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:**
  **values** *array-like*
  : Replacement field values.
* **Returns:**
  **field** *BaseField*
  : Field instance of the same concrete class.

