Skip to content

Latest commit

 

History

History
31 lines (26 loc) · 1.52 KB

variable-objects.rst

File metadata and controls

31 lines (26 loc) · 1.52 KB

Variable objects

The core internal data structure in xarray is the :py~xarray.Variable, which is used as the basic building block behind xarray's :py~xarray.Dataset and :py~xarray.DataArray types. A Variable consists of:

  • dims: A tuple of dimension names.
  • data: The N-dimensional array (typically, a NumPy or Dask array) storing the Variable's data. It must have the same number of dimensions as the length of dims.
  • attrs: An ordered dictionary of metadata associated with this array. By convention, xarray's built-in operations never use this metadata.
  • encoding: Another ordered dictionary used to store information about how these variable's data is represented on disk. See io.encoding for more details.

Variable has an interface similar to NumPy arrays, but extended to make use of named dimensions. For example, it uses dim in preference to an axis argument for methods like mean, and supports compute.broadcasting.

However, unlike Dataset and DataArray, the basic Variable does not include coordinate labels along each axis.

Variable is public API, but because of its incomplete support for labeled data, it is mostly intended for advanced uses, such as in xarray itself or for writing new backends. You can access the variable objects that correspond to xarray objects via the (readonly) :pyDataset.variables <xarray.Dataset.variables> and :pyDataArray.variable <xarray.DataArray.variable> attributes.