# xarray.Variable.set_dims

#### Variable.set_dims(dim, shape=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/variable.py#L1670-L1725)

Return a new variable with given set of dimensions.
This method might be used to attach new dimension(s) to variable.

When possible, this operation does not copy this variable’s data.

* **Parameters:**
  **dim** ([`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) or [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)) – Dimensions to include on the new variable. If a dict, values are
  used to provide the sizes of new dimensions; otherwise, new
  dimensions are inserted with length 1.
* **Returns:**
  [`Variable`](xarray.Variable.html.md#xarray.Variable)
