# xarray.Index.should_add_coord_to_array

#### Index.should_add_coord_to_array(name, var, dims)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/indexes.py#L206-L247)

Define whether or not an index coordinate variable should be added to
a new DataArray.

This method is called repeatedly for each Variable associated with this
index when creating a new DataArray (via its constructor or from a
Dataset) or updating an existing one. The variables associated with this
index are the ones passed to [`Index.from_variables()`](xarray.Index.from_variables.html.md#xarray.Index.from_variables) and/or
returned by [`Index.create_variables()`](xarray.Index.create_variables.html.md#xarray.Index.create_variables).

By default returns `True` if the dimensions of the coordinate variable
are a subset of the array dimensions and `False` otherwise (DataArray
model). This default behavior may be overridden in Index subclasses to
bypass strict conformance with the DataArray model. This is useful for
example to include the (n+1)-dimensional cell boundary coordinate
associated with an interval index.

Returning `False` will either:

- raise a [`CoordinateValidationError`](xarray.CoordinateValidationError.html.md#xarray.CoordinateValidationError) when passing the
  coordinate directly to a new or an existing DataArray, e.g., via
  `DataArray.__init__()` or `DataArray.assign_coords()`
- drop the coordinate (and therefore drop the index) when a new
  DataArray is constructed by indexing a Dataset

* **Parameters:**
  * **name** (`Hashable`) – Name of a coordinate variable associated to this index.
  * **var** ([`Variable`](xarray.Variable.html.md#xarray.Variable)) – Coordinate variable object.
  * **dims** ([`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)) – Dimensions of the new DataArray object being created.
