# xarray.as_variable

### xarray.as_variable(obj, name=None, auto_convert=True)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/variable.py#L141-L239)

Convert an object into a Variable.

* **Parameters:**
  * **obj** ([`object`](https://docs.python.org/3/builtins/functions.html#object)) – Object to convert into a Variable.
    - If the object is already a Variable, return a shallow copy.
    - Otherwise, if the object has ‘dims’ and ‘data’ attributes, convert
      it into a new Variable.
    - If all else fails, attempt to convert the object into a Variable by
      unpacking it into the arguments for creating a new Variable.
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), *optional*) – If provided:
    - obj can be a 1D array, which is assumed to label coordinate values
      along a dimension of this given name.
    - Variables with name matching one of their dimensions are converted
      into IndexVariable objects.
  * **auto_convert** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *optional*) – For internal use only! If True, convert a “dimension” variable into
    an IndexVariable object (deprecated).
* **Returns:**
  **var** ([`Variable`](xarray.Variable.html.md#xarray.Variable)) – The newly created variable.
