# xarray.IndexVariable

### *class* xarray.IndexVariable(dims, data, attrs=None, encoding=None, fastpath=False)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/variable.py#L2989-L3365)

Wrapper for accommodating a pandas.Index in an xarray.Variable.

IndexVariable preserve loaded values in the form of a pandas.Index instead
of a NumPy array. Hence, their values are immutable and must always be one-
dimensional.

They also have a name property, which is the name of their sole dimension
unless another name is given.

#### \_\_init_\_(dims, data, attrs=None, encoding=None, fastpath=False)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/variable.py#L3097-L3111)

* **Parameters:**
  * **dims** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) or [sequence](https://docs.python.org/3/glossary.html#term-sequence) of [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Name(s) of the the data dimension(s). Must be either a string (only
    for 1D data) or a sequence of strings with length equal to the
    number of dimensions.
  * **data** ([array_like](https://numpy.org/doc/stable/glossary.html#term-array_like)) – Data array which supports numpy-like data access.
  * **attrs** ([dict-like](https://docs.python.org/3/glossary.html#term-mapping) or [`None`](https://docs.python.org/3/builtins/constants.html#None), *optional*) – Attributes to assign to the new variable. If None (default), an
    empty attribute dictionary is initialized.
    (see FAQ, [What is your approach to metadata?](../get-help/faq.html.md#approach-to-metadata))
  * **encoding** ([dict-like](https://docs.python.org/3/glossary.html#term-mapping) or [`None`](https://docs.python.org/3/builtins/constants.html#None), *optional*) – Dictionary specifying how to encode this array’s data into a
    serialized format like netCDF4. Currently used keys (for netCDF)
    include ‘_FillValue’, ‘scale_factor’, ‘add_offset’ and ‘dtype’.
    Well-behaved code to serialize a Variable should ignore
    unrecognized encoding items.

### Methods

| [`__init__`](#xarray.IndexVariable.__init__)(dims, data[, attrs, encoding, fastpath])                                      |                                                                                                         |
|-----------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|
| [`all`](xarray.IndexVariable.all.html.md#xarray.IndexVariable.all)([dim])                                                    | Reduce this NamedArray's data by applying `all` along some dimension(s).                                |
| [`any`](xarray.IndexVariable.any.html.md#xarray.IndexVariable.any)([dim])                                                    | Reduce this NamedArray's data by applying `any` along some dimension(s).                                |
| [`argmax`](xarray.IndexVariable.argmax.html.md#xarray.IndexVariable.argmax)([dim, axis, keep_attrs, skipna])                    | Index or indices of the maximum of the Variable over one or more dimensions.                            |
| [`argmin`](xarray.IndexVariable.argmin.html.md#xarray.IndexVariable.argmin)([dim, axis, keep_attrs, skipna])                    | Index or indices of the minimum of the Variable over one or more dimensions.                            |
| [`argsort`](xarray.IndexVariable.argsort.html.md#xarray.IndexVariable.argsort)([axis, kind, order, stable, descending])          | Returns the indices that would sort this array.                                                         |
| `as_numpy`()                                                                                                                            | Coerces wrapped data into a numpy array, returning a Variable.                                          |
| [`astype`](xarray.IndexVariable.astype.html.md#xarray.IndexVariable.astype)(dtype, \*[, order, casting, subok, ...])            | Copy of the Variable object, with data cast to a specified type.                                        |
| [`broadcast_equals`](xarray.IndexVariable.broadcast_equals.html.md#xarray.IndexVariable.broadcast_equals)(other[, equiv])                 | True if two Variables have the values after being broadcast against each other; otherwise False.        |
| `broadcast_to`([dim])                                                                                                                   | Broadcast the NamedArray to a new shape.                                                                |
| [`chunk`](xarray.IndexVariable.chunk.html.md#xarray.IndexVariable.chunk)([chunks, name, lock, inline_array, ...])              | Coerce this array's data into a dask array with the given chunks.                                       |
| [`clip`](xarray.IndexVariable.clip.html.md#xarray.IndexVariable.clip)([min, max])                                             | Return an array whose values are limited to `[min, max]`.                                               |
| [`coarsen`](xarray.IndexVariable.coarsen.html.md#xarray.IndexVariable.coarsen)(windows, func[, boundary, side, ...])             | Apply reduction function.                                                                               |
| `coarsen_reshape`(windows, boundary, side)                                                                                              | Construct a reshaped-array for coarsen                                                                  |
| [`compute`](xarray.IndexVariable.compute.html.md#xarray.IndexVariable.compute)(\*\*kwargs)                                       | Trigger loading data into memory and return a new variable.                                             |
| [`concat`](xarray.IndexVariable.concat.html.md#xarray.IndexVariable.concat)(variables[, dim, positions, ...])                   | Specialized version of Variable.concat for IndexVariable objects.                                       |
| [`conj`](xarray.IndexVariable.conj.html.md#xarray.IndexVariable.conj)()                                                       | Complex-conjugate all elements.                                                                         |
| [`conjugate`](xarray.IndexVariable.conjugate.html.md#xarray.IndexVariable.conjugate)(\*args, \*\*kwargs)                           | a.conj()                                                                                                |
| [`copy`](xarray.IndexVariable.copy.html.md#xarray.IndexVariable.copy)([deep, data])                                           | Returns a copy of this object.                                                                          |
| [`count`](xarray.IndexVariable.count.html.md#xarray.IndexVariable.count)([dim])                                                | Reduce this NamedArray's data by applying `count` along some dimension(s).                              |
| [`cumprod`](xarray.IndexVariable.cumprod.html.md#xarray.IndexVariable.cumprod)([dim, skipna])                                    | Reduce this NamedArray's data by applying `cumprod` (i.e., cumulative product) along some dimension(s). |
| [`cumsum`](xarray.IndexVariable.cumsum.html.md#xarray.IndexVariable.cumsum)([dim, skipna])                                      | Reduce this NamedArray's data by applying `cumsum` (i.e., cumulative sum) along some dimension(s).      |
| `drop_encoding`()                                                                                                                       | Return a new Variable without encoding.                                                                 |
| [`equals`](xarray.IndexVariable.equals.html.md#xarray.IndexVariable.equals)(other[, equiv])                                     | True if two Variables have the same dimensions and values; otherwise False.                             |
| `expand_dims`([dim])                                                                                                                    | Expand the dimensions of the NamedArray.                                                                |
| [`fillna`](xarray.IndexVariable.fillna.html.md#xarray.IndexVariable.fillna)(value)                                              |                                                                                                         |
| [`get_axis_num`](xarray.IndexVariable.get_axis_num.html.md#xarray.IndexVariable.get_axis_num)(dim)                                    | Return axis number(s) corresponding to dimension(s) in this array.                                      |
| [`get_level_variable`](xarray.IndexVariable.get_level_variable.html.md#xarray.IndexVariable.get_level_variable)(level)                      | Return a new IndexVariable from a given MultiIndex level.                                               |
| [`identical`](xarray.IndexVariable.identical.html.md#xarray.IndexVariable.identical)(other[, equiv])                               | Like equals, but also checks attributes.                                                                |
| [`isel`](xarray.IndexVariable.isel.html.md#xarray.IndexVariable.isel)([indexers, missing_dims])                               | Return a new array indexed along the specified dimension(s).                                            |
| [`isnull`](xarray.IndexVariable.isnull.html.md#xarray.IndexVariable.isnull)([keep_attrs])                                       | Test each value in the array for whether it is a missing value.                                         |
| [`item`](xarray.IndexVariable.item.html.md#xarray.IndexVariable.item)(\*args)                                                 | Copy an element of an array to a standard Python scalar and return it.                                  |
| [`load`](xarray.IndexVariable.load.html.md#xarray.IndexVariable.load)()                                                       | Trigger loading data into memory and return this variable.                                              |
| `load_async`()                                                                                                                          | Trigger and await asynchronous loading of data into memory and return this variable.                    |
| [`max`](xarray.IndexVariable.max.html.md#xarray.IndexVariable.max)([dim, skipna])                                            | Reduce this NamedArray's data by applying `max` (i.e., maximum) along some dimension(s).                |
| [`mean`](xarray.IndexVariable.mean.html.md#xarray.IndexVariable.mean)([dim, skipna])                                          | Reduce this NamedArray's data by applying `mean` along some dimension(s).                               |
| [`median`](xarray.IndexVariable.median.html.md#xarray.IndexVariable.median)([dim, skipna])                                      | Reduce this NamedArray's data by applying `median` along some dimension(s).                             |
| [`min`](xarray.IndexVariable.min.html.md#xarray.IndexVariable.min)([dim, skipna])                                            | Reduce this NamedArray's data by applying `min` (i.e., minimum) along some dimension(s).                |
| [`no_conflicts`](xarray.IndexVariable.no_conflicts.html.md#xarray.IndexVariable.no_conflicts)(other[, equiv])                         | True if the intersection of two Variable's non-null data is equal; otherwise false.                     |
| [`notnull`](xarray.IndexVariable.notnull.html.md#xarray.IndexVariable.notnull)([keep_attrs])                                     | Test each value in the array for whether it is not a missing value.                                     |
| [`pad`](xarray.IndexVariable.pad.html.md#xarray.IndexVariable.pad)([pad_width, mode, stat_length, ...])                      | Return a new Variable with padded data.                                                                 |
| `permute_dims`(\*dim[, missing_dims])                                                                                                   | Return a new object with transposed dimensions.                                                         |
| [`prod`](xarray.IndexVariable.prod.html.md#xarray.IndexVariable.prod)([dim, skipna, min_count])                               | Reduce this NamedArray's data by applying `prod` (i.e., product) along some dimension(s).               |
| [`quantile`](xarray.IndexVariable.quantile.html.md#xarray.IndexVariable.quantile)(q[, dim, method, keep_attrs, ...])              | Compute the qth quantile of the data along the specified dimension.                                     |
| [`rank`](xarray.IndexVariable.rank.html.md#xarray.IndexVariable.rank)(dim[, pct])                                             | Ranks the data.                                                                                         |
| [`reduce`](xarray.IndexVariable.reduce.html.md#xarray.IndexVariable.reduce)(func[, dim, axis, keep_attrs, keepdims])            | Reduce this array by applying func along some dimension(s).                                             |
| `reset_encoding`()                                                                                                                      |                                                                                                         |
| [`roll`](xarray.IndexVariable.roll.html.md#xarray.IndexVariable.roll)([shifts])                                               | Return a new Variable with rolled data.                                                                 |
| [`rolling_window`](xarray.IndexVariable.rolling_window.html.md#xarray.IndexVariable.rolling_window)(dim, window, window_dim, \*[, ...]) | Make a rolling_window along dim and add a new_dim to the last place.                                    |
| [`round`](xarray.IndexVariable.round.html.md#xarray.IndexVariable.round)(\*args, \*\*kwargs)                                   |                                                                                                         |
| [`searchsorted`](xarray.IndexVariable.searchsorted.html.md#xarray.IndexVariable.searchsorted)(v[, side, sorter])                      | Find indices where elements of v should be inserted in a to maintain order.                             |
| [`set_dims`](xarray.IndexVariable.set_dims.html.md#xarray.IndexVariable.set_dims)(dim[, shape])                                   | Return a new variable with given set of dimensions.                                                     |
| [`shift`](xarray.IndexVariable.shift.html.md#xarray.IndexVariable.shift)([shifts, fill_value])                                 | Return a new Variable with shifted data.                                                                |
| [`squeeze`](xarray.IndexVariable.squeeze.html.md#xarray.IndexVariable.squeeze)([dim])                                            | Return a new object with squeezed data.                                                                 |
| [`stack`](xarray.IndexVariable.stack.html.md#xarray.IndexVariable.stack)([dim])                                                | Stack any number of existing dim into a single new dimension.                                           |
| [`std`](xarray.IndexVariable.std.html.md#xarray.IndexVariable.std)([dim, skipna, ddof])                                      | Reduce this NamedArray's data by applying `std` (i.e., standard deviation) along some dimension(s).     |
| [`sum`](xarray.IndexVariable.sum.html.md#xarray.IndexVariable.sum)([dim, skipna, min_count])                                 | Reduce this NamedArray's data by applying `sum` along some dimension(s).                                |
| [`to_base_variable`](xarray.IndexVariable.to_base_variable.html.md#xarray.IndexVariable.to_base_variable)()                               | Return this variable as a base xarray.Variable                                                          |
| [`to_dict`](xarray.IndexVariable.to_dict.html.md#xarray.IndexVariable.to_dict)([data, encoding])                                 | Dictionary representation of variable.                                                                  |
| [`to_index`](xarray.IndexVariable.to_index.html.md#xarray.IndexVariable.to_index)()                                               | Convert this variable to a pandas.Index                                                                 |
| [`to_index_variable`](xarray.IndexVariable.to_index_variable.html.md#xarray.IndexVariable.to_index_variable)()                             | Return this variable as an xarray.IndexVariable                                                         |
| `to_numpy`()                                                                                                                            | Coerces wrapped data to numpy and returns a numpy.ndarray                                               |
| [`transpose`](xarray.IndexVariable.transpose.html.md#xarray.IndexVariable.transpose)(\*dim[, missing_dims])                        | Return a new Variable object with transposed dimensions.                                                |
| [`unstack`](xarray.IndexVariable.unstack.html.md#xarray.IndexVariable.unstack)([dim])                                            | Unstack an existing dimension into multiple new dimensions.                                             |
| [`var`](xarray.IndexVariable.var.html.md#xarray.IndexVariable.var)([dim, skipna, ddof])                                      | Reduce this NamedArray's data by applying `var` (i.e., variance) along some dimension(s).               |
| [`where`](xarray.IndexVariable.where.html.md#xarray.IndexVariable.where)(cond[, other])                                        |                                                                                                         |

### Attributes

| [`T`](xarray.IndexVariable.T.html.md#xarray.IndexVariable.T)                     | Return a new object with transposed dimensions.                                                                                |
|-----------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
| [`attrs`](xarray.IndexVariable.attrs.html.md#xarray.IndexVariable.attrs)             | Dictionary of local attributes on this NamedArray.                                                                             |
| [`chunks`](xarray.IndexVariable.chunks.html.md#xarray.IndexVariable.chunks)           | Tuple of block lengths for this NamedArray's data, in order of dimensions, or None if the underlying data is not a dask array. |
| `chunksizes`                                                                                  | Mapping from dimension names to block lengths for this NamedArray's data.                                                      |
| [`data`](xarray.IndexVariable.data.html.md#xarray.IndexVariable.data)               | The Variable's data as an array.                                                                                               |
| [`dims`](xarray.IndexVariable.dims.html.md#xarray.IndexVariable.dims)               | Tuple of dimension names with which this NamedArray is associated.                                                             |
| [`dtype`](xarray.IndexVariable.dtype.html.md#xarray.IndexVariable.dtype)             | Data-type of the array’s elements.                                                                                             |
| [`encoding`](xarray.IndexVariable.encoding.html.md#xarray.IndexVariable.encoding)       | Dictionary of encodings on this variable.                                                                                      |
| [`imag`](xarray.IndexVariable.imag.html.md#xarray.IndexVariable.imag)               | The imaginary part of the variable.                                                                                            |
| [`level_names`](xarray.IndexVariable.level_names.html.md#xarray.IndexVariable.level_names) | Return MultiIndex level names or None if this IndexVariable has no MultiIndex.                                                 |
| [`name`](xarray.IndexVariable.name.html.md#xarray.IndexVariable.name)               |                                                                                                                                |
| [`nbytes`](xarray.IndexVariable.nbytes.html.md#xarray.IndexVariable.nbytes)           | Total bytes consumed by the elements of the data array.                                                                        |
| [`ndim`](xarray.IndexVariable.ndim.html.md#xarray.IndexVariable.ndim)               | Number of array dimensions.                                                                                                    |
| [`real`](xarray.IndexVariable.real.html.md#xarray.IndexVariable.real)               | The real part of the variable.                                                                                                 |
| [`shape`](xarray.IndexVariable.shape.html.md#xarray.IndexVariable.shape)             | Get the shape of the array.                                                                                                    |
| [`size`](xarray.IndexVariable.size.html.md#xarray.IndexVariable.size)               | Number of elements in the array.                                                                                               |
| [`sizes`](xarray.IndexVariable.sizes.html.md#xarray.IndexVariable.sizes)             | Ordered mapping from dimension names to lengths.                                                                               |
| [`values`](xarray.IndexVariable.values.html.md#xarray.IndexVariable.values)           | The variable's data as a numpy.ndarray                                                                                         |
