pandera.api.xarray.components.DataVarΒΆ

class pandera.api.xarray.components.DataVar(*, required=True, alias=None, regex=False, default=None, aligned_with=None, broadcastable_with=None, dtype=None, dims=None, ordered_dims=True, sizes=None, shape=None, coords=None, attrs=None, name=None, checks=None, parsers=None, coerce=False, nullable=False, chunked=None, array_type=None, encoding=None, strict_coords=False, strict_attrs=False, title=None, description=None, metadata=None)[source]ΒΆ

Per-variable schema inside DatasetSchema.

aligned_with / broadcastable_with express grid relationships to other data variables (same shape vs broadcastable). Other fields mirror DataArraySchema (dims, dtype, checks, etc.).

ParametersΒΆ

required

If False, the variable may be absent; default can fill it.

alias

Actual name in the Dataset if different from the key.

default

Filled when required=False and the variable is missing.

aligned_with

Names of variables that must share dims and shape with this one.

broadcastable_with

Names of variables this one must be broadcastable against (see backend).

dtype, dims, sizes, shape, coords, attrs

Structural constraints (sizes and shape are mutually exclusive).

checks, parsers, coerce, nullable, chunked, array_type

Same roles as on DataArraySchema.

encoding

Expected per-variable encoding key-value pairs (e.g. _FillValue, scale_factor, add_offset, dtype, zlib, complevel). Validated against ds[var_name].encoding, which is populated when reading from netCDF/Zarr. Can be a dict[str, Any] or a pydantic.BaseModel class for structured validation.

strict_coords, strict_attrs

Coordinate / attribute strictness for the variable array.

name, title, description, metadata

Documentation / identification metadata.

Methods

__init__(*, required=True, alias=None, regex=False, default=None, aligned_with=None, broadcastable_with=None, dtype=None, dims=None, ordered_dims=True, sizes=None, shape=None, coords=None, attrs=None, name=None, checks=None, parsers=None, coerce=False, nullable=False, chunked=None, array_type=None, encoding=None, strict_coords=False, strict_attrs=False, title=None, description=None, metadata=None)[source]ΒΆ
to_data_array_schema(data_var_key)[source]ΒΆ

Array-level validation spec (no dataset-only fields).

Return type:

DataArraySchema